More setup getting CC to work

This commit is contained in:
Sam 2017-11-07 20:24:56 +00:00 committed by Alexander Meech
parent 570033e3c9
commit a40625825d
10 changed files with 424 additions and 184 deletions

View File

@ -1150,11 +1150,21 @@ public class UtilPlayer
public static void playCustomSound(CustomSound sound)
{
if (sound == null)
{
return;
}
UtilServer.getPlayersCollection().forEach(player -> playCustomSound(player, sound));
}
public static void playCustomSound(Player player, CustomSound sound)
{
if (player == null || sound == null)
{
return;
}
Packet packet;
int protocol = ((CraftPlayer) player).getHandle().getProtocol();
Location location = player.getLocation();

View File

@ -34,6 +34,7 @@ import nautilus.game.arcade.game.games.champions.ChampionsDominate;
import nautilus.game.arcade.game.games.champions.ChampionsTDM;
import nautilus.game.arcade.game.games.champions.modes.SmashDom;
import nautilus.game.arcade.game.games.christmas.Christmas;
import nautilus.game.arcade.game.games.christmasnew.ChristmasNew;
import nautilus.game.arcade.game.games.deathtag.DeathTag;
import nautilus.game.arcade.game.games.dragonescape.DragonEscape;
import nautilus.game.arcade.game.games.dragonescape.DragonEscapeTeams;
@ -147,6 +148,7 @@ public enum GameType
{
Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResChristmas.zip")
}, true),
ChristmasNew(ChristmasNew.class, GameDisplay.ChristmasNew),
DeathTag(DeathTag.class, GameDisplay.DeathTag),
DragonEscape(DragonEscape.class, GameDisplay.DragonEscape),
DragonEscapeTeams(DragonEscapeTeams.class, GameDisplay.DragonEscapeTeams),

View File

@ -43,7 +43,6 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.christmas.kits.KitPlayer;
import nautilus.game.arcade.game.games.christmas.parts.Part;
import nautilus.game.arcade.game.games.christmas.parts.Part1;
@ -58,7 +57,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedSoundEffect;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
public class Christmas extends SoloGame
public class Christmas extends ChristmasCommon
{
private GameTeam _badGuys;
@ -377,7 +376,7 @@ public class Christmas extends SoloGame
}
@EventHandler
public void BarrierDecay(UpdateEvent event)
public void barrierDecay(UpdateEvent event)
{
if (!IsLive())
return;
@ -596,7 +595,7 @@ public class Christmas extends SoloGame
public void DamageCancel(CustomDamageEvent event)
{
if (_sleigh != null)
GetSleigh().Damage(event);
GetSleigh().onDamage(event);
if (event.GetCause() == DamageCause.FALL)
if (event.GetDamageeEntity().getLocation().getY() > 30)
@ -661,7 +660,7 @@ public class Christmas extends SoloGame
//Presents
Scoreboard.writeNewLine();
Scoreboard.write(C.cGreenB + "Presents");
Scoreboard.write(C.cWhite + GetSleigh().GetPresents().size() + " of " + 10);
Scoreboard.write(C.cWhite + GetSleigh().getPresents().size() + " of " + 10);
//Players
Scoreboard.writeNewLine();

View File

@ -4,30 +4,53 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ItemSpawnEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.christmasnew.ChristmasNewAudio;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
public class ChristmasCommon extends TeamGame
public class ChristmasCommon extends SoloGame
{
private static final int BARRIER_BREAK_SQUARED = 400;
private GameTeam _badGuys;
private List<Location> _barrier = new ArrayList<>();
@ -108,6 +131,15 @@ public class ChristmasCommon extends TeamGame
.register(this);
}
@Override
public void ParseData()
{
_barrier = WorldData.GetCustomLocs(String.valueOf(Material.EMERALD_ORE.getId()));
_barrier.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.BARRIER));
_sleighSpawn = WorldData.GetDataLocs("RED").get(0);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void generateTeams(GameStateChangeEvent event)
{
@ -120,13 +152,169 @@ public class ChristmasCommon extends TeamGame
AddTeam(_badGuys);
}
public void sendSantaMessage(String message)
@EventHandler
public void sleighSpawn(GameStateChangeEvent event)
{
GetPlayers(true).forEach(player -> sendSantaMessage(player, message));
if (event.GetState() != GameState.Prepare)
{
return;
}
public void sendSantaMessage(Player player, String message)
List<Location> elfSpawns = getPlayersTeam().GetSpawns();
Manager.runSyncLater(() ->
{
Manager.getPacketHandler().addPacketHandler(
_reindeerPackets,
PacketPlayOutEntityDestroy.class,
PacketPlayOutSpawnEntityLiving.class);
getSleigh();
CreatureAllowOverride = true;
for (Location location : elfSpawns)
{
Villager elf = location.getWorld().spawn(UtilAlg.getRandomLocation(location, 2, 0, 2), Villager.class);
elf.setBaby();
elf.setAgeLock(true);
elf.setCustomName("Elf");
elf.setCustomNameVisible(true);
}
CreatureAllowOverride = false;
}, GetPlayers(true).size() * TickPerTeleport + 10);
}
@EventHandler
public void sleighUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK || _sleigh == null)
{
return;
}
for (SleighHorse horse : _sleigh.getHorses())
{
horse.onTick();
}
if (!IsLive())
{
return;
}
getSleigh().Update();
}
@EventHandler(priority = EventPriority.LOWEST)
public void damageCancel(CustomDamageEvent event)
{
if (_sleigh != null)
{
_sleigh.onDamage(event);
}
if (event.GetCause() == DamageCause.FALL)
{
event.SetCancelled("Fall Damage");
}
}
@EventHandler
public void updateReigns(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER || !InProgress() || _sleigh == null || _sleigh.getSanta() == null)
{
return;
}
Entity santa = ((CraftEntity) _sleigh.getSanta()).getHandle();
for (SleighHorse horse : _sleigh.getHorses())
{
if (horse.Ent == null || !horse.Ent.isValid())
{
continue;
}
PacketPlayOutAttachEntity packet = new PacketPlayOutAttachEntity(1, ((CraftHorse) horse.Ent).getHandle(), santa);
for (Player player : UtilServer.getPlayersCollection())
{
UtilPlayer.sendPacket(player, packet);
}
}
}
@EventHandler
public void barrierDecay(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !IsLive())
{
return;
}
Location breakAt = null;
for (Location loc : _barrier)
{
if (UtilMath.offsetSquared(getSleigh().GetLocation(), loc) > BARRIER_BREAK_SQUARED)
{
continue;
}
breakAt = loc;
}
if (breakAt != null)
{
_barrier.remove(breakAt);
barrierBreak(breakAt);
}
}
private void barrierBreak(Location location)
{
MapUtil.QuickChangeBlockAt(location, Material.AIR);
for (Block block : UtilBlock.getSurrounding(location.getBlock(), false))
{
if (_barrier.remove(block.getLocation()))
{
barrierBreak(block.getLocation());
}
}
}
@EventHandler
public void combust(EntityCombustEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void itemSpawn(ItemSpawnEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void blockFade(BlockFadeEvent event)
{
event.setCancelled(true);
}
public void sendSantaMessage(String message, ChristmasNewAudio audio)
{
GetPlayers(true).forEach(player -> sendSantaMessage(player, message, audio));
}
public void sendSantaMessage(Player player, String message, ChristmasNewAudio audio)
{
UtilPlayer.playCustomSound(player, audio);
player.sendMessage(getSantaMessage(message));
}

View File

@ -75,7 +75,7 @@ public class Sleigh
PresentSlots.add(new SleighPart(this, 6, 0, 0, loc.clone(), 1, -1));
//Sleigh
SleighEnts = new ArrayList<SleighPart>();
SleighEnts = new ArrayList<>();
SleighEnts.addAll(PresentSlots);

View File

@ -3,6 +3,17 @@ package nautilus.game.arcade.game.games.christmas;
import java.util.HashSet;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.Vector3f;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
@ -18,17 +29,6 @@ import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.Vector3f;
public class SleighHorse
{
@ -101,18 +101,18 @@ public class SleighHorse
int x = xP + pX;
int y = yP;
int z = zP + pZ;
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
{
PacketPlayOutEntity relMove = pX != 0 || pZ != 0 ? new PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook()
: new PacketPlayOutEntity.PacketPlayOutRelEntityMove();
relMove.a = hornsAndNose[i];
relMove.b = (byte) x;
relMove.c = (byte) y;
relMove.d = (byte) z;
relMove.e = ((byte) (int) (newLocation.getYaw() * 256.0F / 360.0F));
packets1_8[i] = relMove;
}
else
// if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
// {
// PacketPlayOutEntity relMove = pX != 0 || pZ != 0 ? new PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook()
// : new PacketPlayOutEntity.PacketPlayOutRelEntityMove();
// relMove.a = hornsAndNose[i];
// relMove.b = (byte) x;
// relMove.c = (byte) y;
// relMove.d = (byte) z;
// relMove.e = ((byte) (int) (newLocation.getYaw() * 256.0F / 360.0F));
// packets1_8[i] = relMove;
// }
// else
{
x = (int) Math.floor(32 * newLocation.getX());
y = (int) Math.floor(32 * newLocation.getY());

View File

@ -93,6 +93,7 @@ public class SleighPart
ItemStack head = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta meta = (LeatherArmorMeta)head.getItemMeta();
meta.setColor(Color.RED);
meta.spigot().setUnbreakable(true);
head.setItemMeta(meta);

View File

@ -1,8 +1,12 @@
package nautilus.game.arcade.game.games.christmasnew;
import org.bukkit.event.EventHandler;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.games.christmas.ChristmasCommon;
import nautilus.game.arcade.game.games.christmas.kits.KitPlayer;
import nautilus.game.arcade.kit.Kit;
public class ChristmasNew extends ChristmasCommon
@ -17,7 +21,20 @@ public class ChristmasNew extends ChristmasCommon
{
super(manager, GameType.ChristmasNew, new Kit[]
{
new KitPlayer(manager)
}, DESCRIPTION);
PrepareTime = 2000;
}
@EventHandler
public void gameStart(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
sendSantaMessage("Testing music", ChristmasNewAudio.TEST);
}
}

View File

@ -2,15 +2,15 @@ package nautilus.game.arcade.game.games.christmasnew;
import mineplex.core.common.util.UtilPlayer.CustomSound;
enum ChristmasAudio implements CustomSound
public enum ChristmasNewAudio implements CustomSound
{
TEST("test")
;
private final String _audioPath;
ChristmasAudio(String audioPath)
ChristmasNewAudio(String audioPath)
{
_audioPath = audioPath;
}

View File

@ -0,0 +1,23 @@
package nautilus.game.arcade.game.games.christmasnew.section;
import org.bukkit.event.Listener;
import nautilus.game.arcade.game.games.christmasnew.ChristmasNew;
public abstract class Section implements Listener
{
private final ChristmasNew _host;
public Section(ChristmasNew host)
{
_host = host;
}
public abstract void onRegister();
public abstract void onUnregister();
public abstract boolean isComplete();
}