Make some adjustments from comparing branches

This commit is contained in:
Sam 2018-06-21 18:19:38 +01:00 committed by Alexander Meech
parent a304f6c4a7
commit c24f799503
14 changed files with 75 additions and 102 deletions

View File

@ -1,67 +0,0 @@
package nautilus.game.arcade.game.games;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
/**
* AbsorptionFix takes care of Absorption being ignored
* use this if you want to give out Golden apples
* it will convert Absorbtion into Health boost
*
* @author xXVevzZXx
*/
public class AbsorptionFix implements Listener
{
private final Game _host;
public AbsorptionFix(Game game)
{
_host = game;
game.Manager.registerEvents(this);
}
@EventHandler
public void convertAbsorption(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
for (Player player : _host.GetPlayers(true))
{
if (player.hasPotionEffect(PotionEffectType.ABSORPTION))
{
for (PotionEffect effect : player.getActivePotionEffects())
{
if (effect.getType().toString().equalsIgnoreCase(PotionEffectType.ABSORPTION.toString()))
{
player.removePotionEffect(PotionEffectType.ABSORPTION);
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
player.setHealth(player.getHealth() + 4);
}
}
}
}
}
@EventHandler
public void disable(GameStateChangeEvent event)
{
if (event.GetState() == GameState.End || event.GetState() == GameState.Dead)
{
HandlerList.unregisterAll(this);
}
}
}

View File

@ -17,7 +17,7 @@ import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.bridge.Bridge;
/**
@ -33,7 +33,8 @@ public class InsaneBridges extends Bridge
{
super(manager, GameType.Brawl);
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
Manager.GetDamage().SetEnabled(false);

View File

@ -3,7 +3,7 @@ package nautilus.game.arcade.game.games.bridge.modes;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.bridge.Bridge;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -45,7 +45,8 @@ public class LuckyBridges extends Bridge
Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS,
Material.GOLD_PICKAXE, Material.GOLD_AXE, Material.GOLD_SWORD, Material.GOLDEN_APPLE));
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
}
@EventHandler

View File

@ -28,7 +28,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.bridge.Bridge;
import net.md_5.bungee.api.ChatColor;
@ -51,7 +51,8 @@ public class OverpoweredBridge extends Bridge
Manager.GetDamage().SetEnabled(false);
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
_starterItems = new HashMap<>();
_starterItems.put(Material.WOOD, 64);

View File

@ -24,7 +24,7 @@ import mineplex.core.common.util.UtilServer;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.bridge.Bridge;
/**
@ -41,7 +41,8 @@ public class UHCBridges extends Bridge
SoupEnabled = false;
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
ShapedRecipe headApple = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1));
headApple.shape("GGG", "GHG", "GGG");

View File

@ -44,7 +44,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.cakewars.capturepoint.CakePointModule;
import nautilus.game.arcade.game.games.cakewars.general.CakeBatModule;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
@ -192,7 +192,8 @@ public class CakeWars extends TeamGame
manager.GetDamage().setConstantKnockback(GAME_KNOCKBACK);
manager.GetCreature().SetDisableCustomDrops(true);
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
new CompassModule()
.register(this);

View File

@ -13,7 +13,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
@ -31,7 +30,6 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -294,6 +292,11 @@ public class CakePlayerModule extends CakeModule
@EventHandler
public void spawnProtection(CustomDamageEvent event)
{
if (event.IsCancelled())
{
return;
}
Player damager = event.GetDamagerPlayer(true);
Player damagee = event.GetDamageePlayer();
@ -302,16 +305,9 @@ public class CakePlayerModule extends CakeModule
damager.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
}
if (damagee != null)
if (damagee != null && damagee.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE))
{
if (event.GetCause() == DamageCause.SUFFOCATION && !Recharge.Instance.use(damagee, "Suffocation", 1100, false, false))
{
event.SetCancelled("Suffocation Rate");
}
else if (damagee.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE))
{
event.SetCancelled("Damage Resistance");
}
event.SetCancelled("Damage Resistance");
}
}

View File

@ -47,7 +47,7 @@ public class CakeSheep extends CakeSpecialItem implements Listener
"",
"Spawns Polly The Sheep...",
"After " + C.cRed + "5 seconds" + C.cGray + " she explodes destroying",
"all player placed blocks around her.",
"nearby player placed blocks.",
"If she is killed she does not explode.",
"Warning! Polly has a", C.cRed + "20 second" + C.cGray + " cooldown between uses."
)
@ -138,8 +138,7 @@ public class CakeSheep extends CakeSpecialItem implements Listener
// I originally was going to use the NMS way to get the "hardness" of a block
// but I decided against it as the values were way too varied for this game.
// The value for chance should be taken from if the blocks was within half of
// the explosion radius, after that it decreases.
// The value for chance should be taken from if the block was right next to the sheep.
switch (block.getType())
{
case WOOL:

View File

@ -96,7 +96,7 @@ public enum CakeTeamItem implements CakeItem
RESOURCE(
"Resource Generator",
new ItemStack(Material.NETHER_STAR),
"When an item generates in your generator it also generate %s extra.",
"When an item generates in your generator it will also generate %s extra.",
Pair.create("1", 10),
Pair.create("2", 20)
),
@ -104,8 +104,8 @@ public enum CakeTeamItem implements CakeItem
"Healing Station",
new ItemStack(Material.GOLDEN_APPLE),
"Receive %s when within %s of your cake.",
Pair.create("Regeneration I;5 blocks", 8),
Pair.create("Regeneration I;8 blocks", 12)
Pair.create("Regeneration I;" + CakeShopModule.getHealingStationRadius(1) + " blocks", 8),
Pair.create("Regeneration I;" + CakeShopModule.getHealingStationRadius(2) + " blocks", 12)
)
{
@Override

View File

@ -2,7 +2,7 @@ package nautilus.game.arcade.game.games.sheep.modes;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.sheep.SheepGame;
import nautilus.game.arcade.game.games.sheep.modes.kits.KitShepherd;
import nautilus.game.arcade.game.modules.TeamArmorModule;
@ -26,7 +26,8 @@ public class OverpoweredSheepQuest extends SheepGame
getModule(TeamArmorModule.class)
.dontGiveTeamArmor();
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
}
@Override

View File

@ -2,7 +2,7 @@ package nautilus.game.arcade.game.games.skywars.modes;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.skywars.TeamSkywars;
/**
@ -17,7 +17,8 @@ public class OverpoweredSkywars extends TeamSkywars
{
super(manager, GameType.Brawl);
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
}
@Override

View File

@ -13,7 +13,7 @@ import org.bukkit.scoreboard.Objective;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.skywars.SoloSkywars;
/**
@ -30,7 +30,8 @@ public class UHCSkywars extends SoloSkywars
SoupEnabled = false;
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
}
@EventHandler

View File

@ -105,7 +105,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.uhc.components.UHCBorder;
import nautilus.game.arcade.game.games.uhc.components.UHCFreezer;
import nautilus.game.arcade.game.games.uhc.components.UHCSpeedMode;
@ -307,7 +307,8 @@ public abstract class UHC extends Game
.register(this);
new OreVeinEditorModule().removeNonAirVeins().register(this);
new RejoinModule().register(this);
new AbsorptionFix(this);
new AbsorptionFix()
.register(this);
registerStatTrackers(new CollectFoodStat(this), new HoeCraftingStat(this), new LuckyMinerStat(this), new HalfHeartHealStat(this));

View File

@ -0,0 +1,36 @@
package nautilus.game.arcade.game.modules;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class AbsorptionFix extends Module
{
@EventHandler
public void convertAbsorption(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
for (Player player : getGame().GetPlayers(true))
{
for (PotionEffect effect : player.getActivePotionEffects())
{
if (effect.getType().toString().equalsIgnoreCase(PotionEffectType.ABSORPTION.toString()))
{
player.removePotionEffect(PotionEffectType.ABSORPTION);
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
UtilPlayer.health(player, 4);
}
}
}
}
}