Compatibility fixes for 1.1-R6. War doesn't use any Craftbukkit or net.minecraft classes anymore. Removed getLogger override which was breaking Bukkit's calls to the plugin's logger accessor - weird.

This commit is contained in:
taoneill 2012-03-03 13:21:41 -05:00
parent 61d691c1dd
commit f8e771c9e0
12 changed files with 75 additions and 214 deletions

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java"/> <classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/> <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="src" path="src/main/resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -10,11 +10,6 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>net.sourceforge.metrics.builder</name> <name>net.sourceforge.metrics.builder</name>
<arguments> <arguments>
@ -25,6 +20,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>

View File

@ -3,7 +3,7 @@
<groupId>com.tommytony</groupId> <groupId>com.tommytony</groupId>
<artifactId>war</artifactId> <artifactId>war</artifactId>
<version>1.7</version> <version>1.7.1-PREVIEW</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>War</name> <name>War</name>
@ -53,18 +53,6 @@
</resources> </resources>
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.1-R3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.1-R3</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.getspout</groupId> <groupId>org.getspout</groupId>
<artifactId>spoutpluginapi</artifactId> <artifactId>spoutpluginapi</artifactId>
@ -83,6 +71,20 @@
<version>1.8.5</version> <version>1.8.5</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.1-R6</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.1-R6</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -824,10 +824,6 @@ public class War extends JavaPlugin {
} }
} }
public Logger getLogger() {
return this.logger;
}
public boolean isSpoutServer() { public boolean isSpoutServer() {
return this.isSpoutServer; return this.isSpoutServer;
} }

View File

@ -13,7 +13,6 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.entity.CraftItem;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -42,7 +41,7 @@ import com.tommytony.war.structure.ZoneLobby;
import com.tommytony.war.structure.ZoneWallGuard; import com.tommytony.war.structure.ZoneWallGuard;
import com.tommytony.war.utility.LoadoutSelection; import com.tommytony.war.utility.LoadoutSelection;
import com.tommytony.war.utility.PlayerState; import com.tommytony.war.utility.PlayerState;
import com.tommytony.war.utility.PotionEffect; import com.tommytony.war.utility.PotionEffectHelper;
import com.tommytony.war.volume.ZoneVolume; import com.tommytony.war.volume.ZoneVolume;
/** /**
@ -284,9 +283,10 @@ public class Warzone {
// nom drops // nom drops
for(Entity entity : (this.getWorld().getEntities())) { for(Entity entity : (this.getWorld().getEntities())) {
if (!(entity instanceof Item) && !(entity instanceof CraftItem)) { if (!(entity instanceof Item)) {
continue; continue;
} }
// validate position // validate position
if (!this.getVolume().contains(entity.getLocation())) { if (!this.getVolume().contains(entity.getLocation())) {
continue; continue;
@ -332,7 +332,7 @@ public class Warzone {
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
} }
// clear potion effects // clear potion effects
PotionEffect.clearPotionEffects(player); PotionEffectHelper.clearPotionEffects(player);
boolean isFirstRespawn = false; boolean isFirstRespawn = false;
if (!this.getLoadoutSelections().keySet().contains(player.getName())) { if (!this.getLoadoutSelections().keySet().contains(player.getName())) {
@ -445,7 +445,6 @@ public class Warzone {
public void keepPlayerState(Player player) { public void keepPlayerState(Player player) {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
ItemStack[] contents = inventory.getContents(); ItemStack[] contents = inventory.getContents();
List<PotionEffect> potionEffects = PotionEffect.getCurrentPotionEffects(player);
String playerTitle = player.getName(); String playerTitle = player.getName();
if (War.war.isSpoutServer()) { if (War.war.isSpoutServer()) {
@ -462,7 +461,7 @@ public class Warzone {
player.getExhaustion(), player.getExhaustion(),
player.getSaturation(), player.getSaturation(),
player.getFoodLevel(), player.getFoodLevel(),
potionEffects, player.getActivePotionEffects(),
playerTitle, playerTitle,
player.getLevel(), player.getLevel(),
player.getExp())); player.getExp()));
@ -478,7 +477,7 @@ public class Warzone {
player.setExhaustion(originalState.getExhaustion()); player.setExhaustion(originalState.getExhaustion());
player.setSaturation(originalState.getSaturation()); player.setSaturation(originalState.getSaturation());
player.setFoodLevel(originalState.getFoodLevel()); player.setFoodLevel(originalState.getFoodLevel());
PotionEffect.restorePotionEffects(player, originalState.getPotionEffects()); PotionEffectHelper.restorePotionEffects(player, originalState.getPotionEffects());
player.setLevel(originalState.getLevel()); player.setLevel(originalState.getLevel());
player.setExp(originalState.getExp()); player.setExp(originalState.getExp());

View File

@ -6,7 +6,6 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.tommytony.war.War; import com.tommytony.war.War;
import com.tommytony.war.command.*;
/** /**

View File

@ -8,11 +8,8 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.ContainerBlock;
import org.bukkit.block.NoteBlock; import org.bukkit.block.NoteBlock;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftTNTPrimed;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,7 +18,6 @@ import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -31,6 +27,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer; import org.getspout.spoutapi.player.SpoutPlayer;
@ -266,7 +263,7 @@ public class WarEntityListener implements Listener {
String deathMessage = ""; String deathMessage = "";
String defenderString = Team.getTeamByPlayerName(d.getName()).getKind().getColor() + d.getName(); String defenderString = Team.getTeamByPlayerName(d.getName()).getKind().getColor() + d.getName();
if (event.getDamager() instanceof CraftTNTPrimed) { if (event.getDamager() instanceof TNTPrimed) {
deathMessage = defenderString + ChatColor.WHITE + " exploded"; deathMessage = defenderString + ChatColor.WHITE + " exploded";
} else { } else {
deathMessage = defenderString + ChatColor.WHITE + " died"; deathMessage = defenderString + ChatColor.WHITE + " died";
@ -352,11 +349,11 @@ public class WarEntityListener implements Listener {
if (dont.getState() instanceof Sign) { if (dont.getState() instanceof Sign) {
String[] lines = ((Sign)dont.getState()).getLines(); String[] lines = ((Sign)dont.getState()).getLines();
deferred = new DeferredBlockReset(dont.getX(), dont.getY(), dont.getZ(), dont.getTypeId(), dont.getData(), lines); deferred = new DeferredBlockReset(dont.getX(), dont.getY(), dont.getZ(), dont.getTypeId(), dont.getData(), lines);
} else if (dont.getState() instanceof ContainerBlock) { } else if (dont.getState() instanceof InventoryHolder) {
ItemStack[] contents = ((ContainerBlock)dont.getState()).getInventory().getContents(); ItemStack[] contents = ((InventoryHolder)dont.getState()).getInventory().getContents();
Block worldBlock = dont.getWorld().getBlockAt(dont.getLocation()); Block worldBlock = dont.getWorld().getBlockAt(dont.getLocation());
if (worldBlock.getState() instanceof ContainerBlock) { if (worldBlock.getState() instanceof InventoryHolder) {
((ContainerBlock)worldBlock.getState()).getInventory().clear(); ((InventoryHolder)worldBlock.getState()).getInventory().clear();
} }
deferred = new DeferredBlockReset(dont.getX(), dont.getY(), dont.getZ(), dont.getTypeId(), dont.getData(), copyItems(contents)); deferred = new DeferredBlockReset(dont.getX(), dont.getY(), dont.getZ(), dont.getTypeId(), dont.getData(), copyItems(contents));
} else if (dont.getTypeId() == Material.NOTE_BLOCK.getId()) { } else if (dont.getTypeId() == Material.NOTE_BLOCK.getId()) {
@ -479,11 +476,8 @@ public class WarEntityListener implements Listener {
Team team = Team.getTeamByPlayerName(player.getName()); Team team = Team.getTeamByPlayerName(player.getName());
if (team != null && team.getSpawnVolume().contains(player.getLocation())) { if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
// smother out the fire that didn't burn out when you respawned // smother out the fire that didn't burn out when you respawned
// Stop fire (upcast, watch out!) // Stop fire
if (player instanceof CraftPlayer) { player.setFireTicks(0);
net.minecraft.server.Entity playerEntity = ((CraftPlayer) player).getHandle();
playerEntity.fireTicks = 0;
}
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -2,14 +2,12 @@ package com.tommytony.war.event;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Random;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.entity.CraftItem;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result; import org.bukkit.event.Event.Result;
@ -19,16 +17,13 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerInventoryEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer; import org.getspout.spoutapi.player.SpoutPlayer;
@ -149,10 +144,8 @@ public class WarPlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} else { } else {
Item item = event.getItem(); Item item = event.getItem();
if (item != null && item instanceof CraftItem) { if (item != null) {
CraftItem cItem = (CraftItem) item; ItemStack itemStack = item.getItemStack();
if (cItem != null) {
ItemStack itemStack = cItem.getItemStack();
if (itemStack != null && itemStack.getType() == team.getKind().getMaterial() && player.getInventory().contains(new ItemStack(team.getKind().getMaterial(), team.getKind().getData()))) { if (itemStack != null && itemStack.getType() == team.getKind().getMaterial() && player.getInventory().contains(new ItemStack(team.getKind().getMaterial(), team.getKind().getData()))) {
// Can't pick up a second precious block // Can't pick up a second precious block
event.setCancelled(true); event.setCancelled(true);
@ -163,27 +156,6 @@ public class WarPlayerListener implements Listener {
} }
} }
} }
}
@EventHandler
public void onInventoryOpen(final PlayerInventoryEvent event) {
if (War.war.isLoaded()) {
Player player = event.getPlayer();
Inventory inventory = event.getInventory();
Team team = Team.getTeamByPlayerName(player.getName());
if (team != null && inventory instanceof PlayerInventory) {
// make sure the player doesn't have too many precious blocks
// or illegal armor (i.e. armor not found in loadout)
PlayerInventory playerInv = (PlayerInventory) inventory;
ItemStack teamKindBlock = new ItemStack(team.getKind().getMaterial(), team.getKind().getData());
if (playerInv.contains(teamKindBlock, 2)) {
playerInv.remove(teamKindBlock);
playerInv.addItem(teamKindBlock);
War.war.badMsg(player, "All that " + team.getName() + " must have been heavy!");
}
}
}
}
@EventHandler @EventHandler
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) { public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {

View File

@ -9,11 +9,11 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.ContainerBlock;
import org.bukkit.block.NoteBlock; import org.bukkit.block.NoteBlock;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.tommytony.war.utility.DeferredBlockReset; import com.tommytony.war.utility.DeferredBlockReset;
@ -75,8 +75,8 @@ public class DeferredBlockResetsJob implements Runnable {
worldBlock.setType(Material.getMaterial(reset.getBlockType())); worldBlock.setType(Material.getMaterial(reset.getBlockType()));
worldBlock.setData(reset.getBlockData()); worldBlock.setData(reset.getBlockData());
BlockState state = worldBlock.getState(); BlockState state = worldBlock.getState();
if (state instanceof ContainerBlock) { if (state instanceof InventoryHolder) {
ContainerBlock container = (ContainerBlock) state; InventoryHolder container = (InventoryHolder) state;
if (items != null) { if (items != null) {
int ii = 0; int ii = 0;
container.getInventory().clear(); container.getInventory().clear();

View File

@ -1,9 +1,10 @@
package com.tommytony.war.utility; package com.tommytony.war.utility;
import java.util.List; import java.util.Collection;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
public class PlayerState { public class PlayerState {
@ -17,12 +18,12 @@ public class PlayerState {
private final int foodLevel; private final int foodLevel;
private final int health; private final int health;
private final GameMode gamemode; private final GameMode gamemode;
private final List<PotionEffect> potionEffects; private final Collection<PotionEffect> potionEffects;
private final String playerTitle; private final String playerTitle;
private final float exp; private final float exp;
private final int level; private final int level;
public PlayerState(GameMode gamemode, ItemStack[] contents, ItemStack helmet, ItemStack chest, ItemStack legs, ItemStack feet, int health, float exhaustion, float saturation, int foodLevel, List<PotionEffect> potionEffects, String playerTitle, int level, float exp) { public PlayerState(GameMode gamemode, ItemStack[] contents, ItemStack helmet, ItemStack chest, ItemStack legs, ItemStack feet, int health, float exhaustion, float saturation, int foodLevel, Collection<PotionEffect> potionEffects, String playerTitle, int level, float exp) {
this.gamemode = gamemode; this.gamemode = gamemode;
this.health = health; this.health = health;
this.exhaustion = exhaustion; this.exhaustion = exhaustion;
@ -99,7 +100,7 @@ public class PlayerState {
return gamemode; return gamemode;
} }
public List<PotionEffect> getPotionEffects() { public Collection<PotionEffect> getPotionEffects() {
return potionEffects; return potionEffects;
} }

View File

@ -1,125 +0,0 @@
package com.tommytony.war.utility;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.server.MobEffect;
import net.minecraft.server.MobEffectList;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PotionEffect {
private int id;
private int amplifier;
private int time;
public PotionEffect(int id, int amplifier, int time) {
this.setId(id);
this.setAmplifier(amplifier);
this.setTime(time);
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setAmplifier(int amplifier) {
this.amplifier = amplifier;
}
public int getAmplifier() {
return amplifier;
}
public void setTime(int time) {
this.time = time;
}
public int getTime() {
return time;
}
public static List<PotionEffect> getCurrentPotionEffects(Player player) {
List<PotionEffect> effects = new ArrayList<PotionEffect>();
for(int i = 1; i < 20; i++)
{
if(((CraftPlayer)player).getHandle().hasEffect(enchantIdToList(i)))
{
MobEffect mobEffect = ((CraftPlayer)player).getHandle().getEffect(enchantIdToList(i));
effects.add(new PotionEffect(mobEffect.getEffectId(), mobEffect.getAmplifier(), mobEffect.getDuration()));
}
}
return effects;
}
public static void restorePotionEffects(Player player, List<PotionEffect> potionEffects) {
clearPotionEffects(player);
for (PotionEffect effect : potionEffects) {
((CraftPlayer)player).getHandle().addEffect(new MobEffect(effect.getId(), effect.getTime(), effect.getAmplifier()));
}
}
public static void clearPotionEffects(Player player) {
for (int i = 1; i < 20; i++) {
if(((CraftPlayer)player).getHandle().hasEffect(enchantIdToList(i)))
{
int amplifier = ((CraftPlayer)player).getHandle().getEffect(enchantIdToList(i)).getAmplifier();
((CraftPlayer)player).getHandle().addEffect(new MobEffect(i, -1, amplifier + 1));
}
}
}
private static MobEffectList enchantIdToList(int id) {
switch (id) {
case 1:
return MobEffectList.FASTER_MOVEMENT;
case 2:
return MobEffectList.SLOWER_MOVEMENT;
case 3:
return MobEffectList.FASTER_DIG;
case 4:
return MobEffectList.SLOWER_DIG;
case 5:
return MobEffectList.INCREASE_DAMAGE;
case 6:
return MobEffectList.HEAL;
case 7:
return MobEffectList.HARM;
case 8:
return MobEffectList.JUMP;
case 9:
return MobEffectList.CONFUSION;
case 10:
return MobEffectList.REGENERATION;
case 11:
return MobEffectList.RESISTANCE;
case 12:
return MobEffectList.FIRE_RESISTANCE;
case 13:
return MobEffectList.WATER_BREATHING;
case 14:
return MobEffectList.INVISIBILITY;
case 15:
return MobEffectList.BLINDNESS;
case 16:
return MobEffectList.NIGHT_VISION;
case 17:
return MobEffectList.HUNGER;
case 18:
return MobEffectList.WEAKNESS;
case 19:
return MobEffectList.POISON;
default:
return null;
}
}
}

View File

@ -0,0 +1,23 @@
package com.tommytony.war.utility;
import java.util.Collection;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
public class PotionEffectHelper {
public static void restorePotionEffects(Player player, Collection<PotionEffect> potionEffects) {
clearPotionEffects(player);
for (PotionEffect effect : potionEffects) {
player.addPotionEffect(effect, true);
}
}
public static void clearPotionEffects(Player player) {
for(PotionEffect effect : player.getActivePotionEffects())
{
player.removePotionEffect(effect.getType());
}
}
}