Add a border

This commit is contained in:
Sam 2018-07-18 23:52:26 +01:00 committed by Alexander Meech
parent 4e3bc018e9
commit e20ff69281
7 changed files with 122 additions and 15 deletions

View File

@ -14,6 +14,9 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.server.v1_8_R3.EntityItem;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.apache.commons.lang3.tuple.Triple; import org.apache.commons.lang3.tuple.Triple;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -83,6 +86,7 @@ import mineplex.core.utils.UtilGameProfile;
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent; import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
@ -101,6 +105,7 @@ import nautilus.game.arcade.kit.ChampionsKit;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.LinearUpgradeKit; import nautilus.game.arcade.kit.LinearUpgradeKit;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.managers.GamePlayerManager;
import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.managers.lobby.LobbyManager; import nautilus.game.arcade.managers.lobby.LobbyManager;
import nautilus.game.arcade.missions.BlocksMissionTracker; import nautilus.game.arcade.missions.BlocksMissionTracker;
@ -126,8 +131,6 @@ import nautilus.game.arcade.stats.StatTracker;
import nautilus.game.arcade.stats.WinStatTracker; import nautilus.game.arcade.stats.WinStatTracker;
import nautilus.game.arcade.wineffect.WinEffectManager; import nautilus.game.arcade.wineffect.WinEffectManager;
import nautilus.game.arcade.world.WorldData; import nautilus.game.arcade.world.WorldData;
import net.minecraft.server.v1_8_R3.EntityItem;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
public abstract class Game extends ListenerComponent implements Lifetimed public abstract class Game extends ListenerComponent implements Lifetimed
{ {
@ -414,8 +417,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
Manager = manager; Manager = manager;
_lifetime.register(this); _lifetime.register(this);
// Player List
UtilTabTitle.broadcastHeaderAndFooter(C.cGoldB + gameType.getName(), "Visit " + C.cGreen + "www.mineplex.com" + C.Reset + " for News, Forums and Shop");
// Game // Game
_gameType = gameType; _gameType = gameType;
@ -678,6 +679,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed
public void prepareToRecruit() public void prepareToRecruit()
{ {
UtilTabTitle.broadcastHeaderAndFooter(GamePlayerManager.getHeader(this), GamePlayerManager.FOOTER);
generateTeams(); generateTeams();
recruit(); recruit();
} }
@ -687,7 +690,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
SetState(GameState.Recruit); SetState(GameState.Recruit);
} }
public void generateTeams() public void generateTeams()
{ {
int count = 1; int count = 1;

View File

@ -135,7 +135,7 @@ public class CakeWars extends TeamGame
private final CakePlayerModule _cakePlayerModule; private final CakePlayerModule _cakePlayerModule;
private final CakeSpawnerModule _cakeSpawnerModule; private final CakeSpawnerModule _cakeSpawnerModule;
private final CakeShopModule _cakeShopModule; private final CakeShopModule _cakeShopModule;
private final ChestLootModule _chestLootModule; protected final ChestLootModule _chestLootModule;
private final CustomScoreboardModule _customScoreboardModule; private final CustomScoreboardModule _customScoreboardModule;
private final CapturePointModule _capturePointModule; private final CapturePointModule _capturePointModule;
private final CakePointModule _cakePointModule; private final CakePointModule _cakePointModule;

View File

@ -0,0 +1,22 @@
package nautilus.game.arcade.game.games.cakewars.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class CakeRotEvent extends Event
{
private static final HandlerList HANDLER_LIST = new HandlerList();
public static HandlerList getHandlerList()
{
return HANDLER_LIST;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
}

View File

@ -1,12 +1,16 @@
package nautilus.game.arcade.game.games.cakewars.modes; package nautilus.game.arcade.game.games.cakewars.modes;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -14,6 +18,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
@ -21,6 +26,7 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
@ -31,7 +37,9 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.event.CakeRotEvent;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule; import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.game.games.cakewars.island.CakeIslandModule;
import nautilus.game.arcade.game.games.cakewars.item.CakeSpecialItem; import nautilus.game.arcade.game.games.cakewars.item.CakeSpecialItem;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform; import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeIceBridge; import nautilus.game.arcade.game.games.cakewars.item.items.CakeIceBridge;
@ -46,6 +54,7 @@ import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeBearTrap; import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeBearTrap;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTNTTrap; import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTNTTrap;
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourcePage; import nautilus.game.arcade.game.games.cakewars.ui.CakeResourcePage;
import nautilus.game.arcade.game.modules.chest.ChestLootPool;
public class OPCakeWars extends CakeWars public class OPCakeWars extends CakeWars
{ {
@ -129,6 +138,48 @@ public class OPCakeWars extends CakeWars
event.AddKnockback(GetMode(), 1.25); event.AddKnockback(GetMode(), 1.25);
} }
@EventHandler
public void cakeRot(CakeRotEvent event)
{
WorldBorder border = WorldData.World.getWorldBorder();
border.setCenter(GetSpectatorLocation());
border.setSize(Math.max(WorldData.MaxX, WorldData.MaxZ) * 2);
border.setSize(20, TimeUnit.MINUTES.toMillis(10) / 50);
border.setDamageAmount(0);
UtilTextMiddle.display(C.cRedB + "Sugar Crash", "The border is closing in.", 0, 50, 0, UtilServer.getPlayers());
Manager.runSyncTimer(new BukkitRunnable()
{
@Override
public void run()
{
if (!IsLive())
{
cancel();
return;
}
int size = (int) border.getSize() / 2;
WorldData.MinX = WorldData.MinZ = -size;
WorldData.MaxX = WorldData.MaxZ = size;
}
}, 0, 20);
}
@EventHandler
public void end(GameStateChangeEvent event)
{
if (event.GetState() != GameState.End)
{
return;
}
WorldBorder border = WorldData.World.getWorldBorder();
border.setSize(Integer.MAX_VALUE);
}
@Override @Override
public int getGeneratorRate(CakeResource resource, int current) public int getGeneratorRate(CakeResource resource, int current)
{ {
@ -219,10 +270,8 @@ public class OPCakeWars extends CakeWars
new CakeTNTTrap(8), new CakeTNTTrap(8),
new CakeBearTrap(8) new CakeBearTrap(8)
); );
case STAR:
return super.generateItems(resource);
default: default:
return null; return super.generateItems(resource);
} }
} }
@ -239,6 +288,34 @@ public class OPCakeWars extends CakeWars
); );
} }
@Override
public void generateChests()
{
_chestLootModule.registerChestType(CakeIslandModule.CHEST_TYPE, new ArrayList<>(),
new ChestLootPool()
.addItem(new ItemBuilder(Material.DIAMOND_SWORD)
.addEnchantment(Enchantment.KNOCKBACK, 1)
.setUnbreakable(true)
.build())
.addItem(new ItemBuilder(Material.BOW)
.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1)
.addEnchantment(Enchantment.ARROW_INFINITE, 1)
.build())
.addItem(new ItemBuilder(Material.GOLD_PICKAXE)
.setTitle(C.cGoldB + "The Golden Pickaxe")
.setUnbreakable(true)
.build())
.addItem(CakeShopModule.ENDER_PEARL, 10, 20)
.addItem(CakeWall.ITEM_STACK, 10, 20)
.addItem(CakeIceBridge.ITEM_STACK, 2, 4)
.addItem(CakeSafeTeleport.ITEM_STACK, 2, 4)
.addItem(CakeSheep.ITEM_STACK, 2, 4)
.addItem(new ItemStack(Material.GOLDEN_APPLE), 5, 10)
).destroyAfterOpened(30);
}
@Override @Override
public CakeResourcePage getShopPage(CakeResource resource, Player player) public CakeResourcePage getShopPage(CakeResource resource, Player player)
{ {

View File

@ -52,6 +52,7 @@ import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeModule; import nautilus.game.arcade.game.games.cakewars.CakeModule;
import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.event.CakeRotEvent;
import nautilus.game.arcade.game.games.cakewars.event.CakeWarsEatCakeEvent; import nautilus.game.arcade.game.games.cakewars.event.CakeWarsEatCakeEvent;
import nautilus.game.arcade.game.games.cakewars.shop.CakeItem; import nautilus.game.arcade.game.games.cakewars.shop.CakeItem;
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule; import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule;
@ -64,7 +65,7 @@ public class CakeTeamModule extends CakeModule
{ {
private static final int HOLOGRAM_VIEW_SQUARED = 16; private static final int HOLOGRAM_VIEW_SQUARED = 16;
private static final long CAKE_ROT_TIME = TimeUnit.MINUTES.toMillis(20); private static final long CAKE_ROT_TIME = TimeUnit.MINUTES.toMillis(1);
private static final long CAKE_WARNING_TIME = TimeUnit.MINUTES.toMillis(5); private static final long CAKE_WARNING_TIME = TimeUnit.MINUTES.toMillis(5);
private static final long TRAP_COOLDOWN = TimeUnit.SECONDS.toMillis(10); private static final long TRAP_COOLDOWN = TimeUnit.SECONDS.toMillis(10);
private static final ItemStack[] STARTING_ITEMS = private static final ItemStack[] STARTING_ITEMS =
@ -592,6 +593,8 @@ public class CakeTeamModule extends CakeModule
_game.getModule(CompassModule.class) _game.getModule(CompassModule.class)
.setGiveCompassToAlive(true); .setGiveCompassToAlive(true);
UtilServer.CallEvent(new CakeRotEvent());
} }
return null; return null;

View File

@ -221,7 +221,7 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
private boolean shouldScale(CakeItem item) private boolean shouldScale(CakeItem item)
{ {
return item.getItemStack().getType().getMaxDurability() == 0; return item.getItemType().isMultiBuy();
} }
protected enum CakeShopResult protected enum CakeShopResult

View File

@ -1,7 +1,6 @@
package nautilus.game.arcade.managers; package nautilus.game.arcade.managers;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,6 +37,12 @@ import nautilus.game.arcade.game.GameTeam;
public class GamePlayerManager implements Listener public class GamePlayerManager implements Listener
{ {
public static final String FOOTER = "Visit " + C.cGreen + "www.mineplex.com" + C.Reset + " for News, Forums and Shop";
public static String getHeader(Game game)
{
return C.cGoldB + (game == null ? "Waiting For Players" : game.GetType().getName() + (game.GetMode() == null ? "" : C.cWhiteB + " - " + C.cYellowB + game.GetMode()));
}
final ArcadeManager Manager; final ArcadeManager Manager;
private static final int TEAMMATE_MESSAGE_DELAY = 40; private static final int TEAMMATE_MESSAGE_DELAY = 40;
@ -79,9 +84,7 @@ public class GamePlayerManager implements Listener
Game game = Manager.GetGame(); Game game = Manager.GetGame();
//Player List //Player List
UtilTabTitle.setHeaderAndFooter(player, UtilTabTitle.setHeaderAndFooter(player, getHeader(game), FOOTER);
C.cGoldB + (game == null ? "Waiting For Players" : game.GetType().getName()),
"Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop");
//Lobby Spawn //Lobby Spawn
if (game == null || !game.InProgress()) if (game == null || !game.InProgress())