Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

This commit is contained in:
libraryaddict 2015-12-10 20:02:39 +13:00
commit 1ee1e7a04b
114 changed files with 4008 additions and 1037 deletions

View File

@ -28,7 +28,7 @@
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel target="1.7" />
<bytecodeTargetLevel target="1.8" />
</component>
<component name="JavacSettings">
<option name="GENERATE_NO_WARNINGS" value="true" />

View File

@ -16,7 +16,7 @@
</set>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -56,11 +56,11 @@ public class MotdManager implements Listener, Runnable
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
// String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f";
String motdLine = " §f§l◄ §b§lNew Game§f§l ▬ §3§lChampions CTF§f§l ►";
String motdLine = " §f❄ §2§lWinter Update §f❄ §2§lSnow Fight §f❄";
//String motdLine = " §d§lRank Sale §a§l40% Off");
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
updateMainMotd(" §f§l§m §8§l§m[ §r §6§lMineplex§r §f§lGames§r §8§l§m ]§f§l§m §r", motdLine);
updateMainMotd(" §c§m §f§m §c§m §f§m §2§l§m[ §r §c§lMineplex§r §f§lGames§r §2§l§m ]§f§m §c§m §f§m §c§m §r", motdLine);
System.out.println("Updated Bungee MOTD");
}
}

View File

@ -26,7 +26,7 @@ public enum Rank
//Media
YOUTUBE("YouTube", ChatColor.RED),
YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE),
YOUTUBE_SMALL("YT", ChatColor.DARK_PURPLE),
TWITCH("Twitch", ChatColor.DARK_PURPLE),
//Player

View File

@ -552,8 +552,8 @@ public class UtilBlock
if (diagonals)
{
for (int x = -1; x <= 1; x++)
for (int y = -1; y <= 1; y++)
for (int z = -1; z <= 1; z++)
for (int z = -1; z <= 1; z++)
for (int y = 1; y >= -1; y--)
{
if (x == 0 && y == 0 && z == 0) continue;
@ -563,11 +563,11 @@ public class UtilBlock
else
{
blocks.add(block.getRelative(BlockFace.UP));
blocks.add(block.getRelative(BlockFace.DOWN));
blocks.add(block.getRelative(BlockFace.NORTH));
blocks.add(block.getRelative(BlockFace.SOUTH));
blocks.add(block.getRelative(BlockFace.EAST));
blocks.add(block.getRelative(BlockFace.WEST));
blocks.add(block.getRelative(BlockFace.DOWN));
}
return blocks;
@ -835,7 +835,7 @@ public class UtilBlock
return getBedHead(bed.getBlock()) != null && getBedFoot(bed.getBlock()) != null;
}
public static HashSet<Block> findConnectedBlocks(Block block, HashSet<Block> blocks, int limit)
public static HashSet<Block> findConnectedBlocks(Block source, Block block, HashSet<Block> blocks, int limit, double range)
{
if (blocks == null)
blocks = new HashSet<Block>();
@ -852,10 +852,13 @@ public class UtilBlock
{
if (neighbour.getType() == Material.AIR)
continue;
if (UtilMath.offset(source.getLocation(), neighbour.getLocation()) > range)
continue;
//If neighbour hasn't been searched, recursively search it!
if (!blocks.contains(neighbour))
findConnectedBlocks(neighbour, blocks, limit);
findConnectedBlocks(source, neighbour, blocks, limit, range);
}
return blocks;

View File

@ -1,5 +1,7 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
@ -509,13 +511,21 @@ public class UtilPlayer
if (cur.isDead())
continue;
//Ignore Check
if (ignore != null)
{
for (int i = 0; i < ignore.length; i++)
boolean shouldIgnore = false;
for (Entity ent : ignore)
{
if (cur.equals(ignore[i]))
continue;
if (cur.equals(ent))
{
shouldIgnore = true;
break;
}
}
if (shouldIgnore)
continue;
}
double dist = UtilMath.offset(cur.getLocation(), loc);

View File

@ -1,10 +1,12 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Stream;
import org.bukkit.Bukkit;
import org.bukkit.Server;
@ -18,6 +20,11 @@ public class UtilServer
return getServer().getOnlinePlayers().toArray(new Player[0]);
}
public static Collection<? extends Player> getPlayersCollection()
{
return getServer().getOnlinePlayers();
}
public static List<Player> getSortedPlayers()
{
return getSortedPlayers(new Comparator<Player>()

View File

@ -110,4 +110,29 @@ public class UtilText {
return s.length() <= maxLength ? s : s.substring(0, maxLength);
}
public static <X> String arrayToString(X[] array, String delimiter)
{
StringBuilder string = new StringBuilder();
int index = 0;
for (X x : array)
{
string.append(x.toString());
if (index != array.length - 1)
{
string.append(delimiter);
}
index++;
}
return string.toString();
}
public static <X> String arrayToString(X[] array)
{
return arrayToString(array, null);
}
}

View File

@ -345,7 +345,10 @@ public class AntiHack extends MiniPlugin
}
//Auto-Kick
if (!handled && _clientManager.Get(player).GetRank() != Rank.YOUTUBE && _clientManager.Get(player).GetRank() != Rank.TWITCH)
if (!handled &&
_clientManager.Get(player).GetRank() != Rank.YOUTUBE &&
_clientManager.Get(player).GetRank() != Rank.YOUTUBE_SMALL &&
_clientManager.Get(player).GetRank() != Rank.TWITCH)
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f);

View File

@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.gadgets.ItemBatGun;
import mineplex.core.gadget.gadgets.ItemCoinBomb;
@ -63,6 +64,7 @@ import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.pet.PetManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
@ -91,6 +93,7 @@ public class GadgetManager extends MiniPlugin
private BlockRestore _blockRestore;
private ProjectileManager _projectileManager;
private AchievementManager _achievementManager;
private MountManager _mountManager;
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
@ -99,6 +102,7 @@ public class GadgetManager extends MiniPlugin
private boolean _hideParticles = false;
private int _activeItemSlot = 3;
private boolean _gadgetsEnabled = true;
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
@ -115,6 +119,7 @@ public class GadgetManager extends MiniPlugin
_blockRestore = blockRestore;
_projectileManager = projectileManager;
_achievementManager = achievementManager;
_mountManager = mountManager;
CreateGadgets();
}
@ -491,6 +496,40 @@ public class GadgetManager extends MiniPlugin
return true;
}
public boolean isGadgetEnabled()
{
return _gadgetsEnabled;
}
public void toggleGadgetEnabled()
{
setGadgetEnabled(!_gadgetsEnabled);
}
public void setGadgetEnabled(boolean enabled)
{
if (_gadgetsEnabled != enabled)
{
_gadgetsEnabled = enabled;
DisableAll();
_mountManager.DisableAll();
}
}
@EventHandler
public void GadgetActivate(GadgetActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler
public void MountActivate(MountActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler
public void chissMeow(PlayerToggleSneakEvent event)

View File

@ -19,10 +19,10 @@ public enum GameDisplay
DragonEscapeTeams("Dragon Escape Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 11),
DragonRiders("Dragon Riders", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 12),
Dragons("Dragons", Material.ENDER_STONE, (byte)0, GameCategory.ARCADE, 13),
DragonsTeams("Dragons Teams", Material.ENDER_STONE, (byte)0, GameCategory.TEAM_VARIANT, 14),
DragonsTeams("Dragons Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 14),
Draw("Draw My Thing", Material.BOOK_AND_QUILL, (byte)0, GameCategory.CLASSICS, 15),
Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16),
Gravity("Gravity", Material.ENDER_PORTAL, (byte)0, GameCategory.EXTRA, 18),
Gravity("Gravity", Material.ENDER_PORTAL_FRAME, (byte)0, GameCategory.EXTRA, 18),
Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19),
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52),
@ -64,10 +64,13 @@ public enum GameDisplay
Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52),
SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53),
MonsterMaze("Monster Maze", Material.ROTTEN_FLESH, (byte)0, GameCategory.ARCADE, 55),
MonsterLeague("Monster League", Material.MINECART, (byte)0, GameCategory.ARCADE, 56),
Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54),
ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56),
BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);

View File

@ -67,7 +67,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
MessageHandler messageHandler = new MessageHandler(this);
ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class,
new AnnouncementHandler());
new AnnouncementHandler(clientManager));
ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler);
ServerCommandManager.getInstance()

View File

@ -10,6 +10,7 @@ import mineplex.core.message.MessageManager;
import mineplex.serverdata.commands.AnnouncementCommand;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class AnnounceCommand extends CommandBase<MessageManager>
@ -22,13 +23,25 @@ public class AnnounceCommand extends CommandBase<MessageManager>
@Override
public void Execute(Player caller, String[] args)
{
if (args == null || args.length == 0)
if (args == null || args.length <= 1)
{
Plugin.Help(caller);
}
else
{
new AnnouncementCommand(true, F.combine(args, 0, null, false)).publish();
Rank rank = Rank.ALL;
try
{
rank = Rank.valueOf(args[0]);
}
catch (IllegalArgumentException ex)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!"));
return;
}
new AnnouncementCommand(true, rank.toString(), F.combine(args, 1, null, false)).publish();
}
}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.message.redis;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
@ -13,20 +15,41 @@ import org.bukkit.entity.Player;
public class AnnouncementHandler implements CommandCallback
{
private CoreClientManager _clientManager;
public AnnouncementHandler(CoreClientManager clientManager)
{
_clientManager = clientManager;
}
public void run(ServerCommand command)
{
if (command instanceof AnnouncementCommand)
{
AnnouncementCommand announcementCommand = (AnnouncementCommand)command;
Rank rank;
try
{
rank = Rank.valueOf(announcementCommand.getRank());
}
catch (Exception e)
{
e.printStackTrace();
return;
}
String message = announcementCommand.getMessage();
if (announcementCommand.getDisplayTitle())
UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10);
for (Player player : Bukkit.getOnlinePlayers())
{
UtilPlayer.message(player, F.main("Announcement", C.cAqua + message));
if (_clientManager.hasRank(player, rank))
{
if (announcementCommand.getDisplayTitle())
UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10, player);
UtilPlayer.message(player, F.main("Announcement", C.cAqua + message));
}
}
}
}

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -18,6 +19,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class LagMeter extends MiniPlugin
{
@ -128,9 +130,27 @@ public class LagMeter extends MiniPlugin
sendUpdate(player);
}
}
private String getPrefix(double value)
{
if (value >= 18.0)
return C.cGreen;
else if (value >= 15)
return C.cYellow;
else
return C.cRed;
}
private void sendUpdate(Player player)
{
double[] tps = MinecraftServer.getServer().recentTps;
String mcString = "";
for (int i = 0; i < tps.length; i++)
{
mcString += getPrefix(tps[i]) + (double)Math.round(tps[i] * 100.0D) / 100.0D;
if (i < tps.length - 1) mcString += C.cWhite + ", ";
}
player.sendMessage(" ");
player.sendMessage(" ");
player.sendMessage(" ");
@ -138,6 +158,8 @@ public class LagMeter extends MiniPlugin
player.sendMessage(" ");
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Live-------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecond)));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Avg--------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecondAverage * 20)));
player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MC Timings (5,10,15 min avg)"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + mcString));
player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MEM"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB");

View File

@ -75,7 +75,7 @@ public class MountCart extends Mount<SingleEntityMountData<Minecart>>
if (event.getRightClicked() == null)
return;
SingleEntityMountData<Minecart> mount = GetActive().get(event.getPlayer());
SingleEntityMountData<Minecart> mount = getMountData(event.getRightClicked());
if(mount == null) return;

View File

@ -30,11 +30,11 @@ public class MountSlime extends Mount<SingleEntityMountData<Slime>>
{
super(manager, "Slime Mount", Material.SLIME_BALL, (byte)0, new String[]
{
ChatColor.RESET + "Bounce around on your very",
ChatColor.RESET + "own personal slime friend!",
ChatColor.RESET + "Bounce around on your very",
ChatColor.RESET + "own personal slime friend!",
},
15000);
KnownPackage = false;
}
@ -42,153 +42,155 @@ public class MountSlime extends Mount<SingleEntityMountData<Slime>>
{
player.leaveVehicle();
player.eject();
//Remove other mounts
Manager.DeregisterAll(player);
SingleEntityMountData<Slime> mount = new SingleEntityMountData<Slime>(player, player.getWorld().spawn(player.getLocation(), Slime.class));
mount.getEntity().setSize(2);
mount.getEntity().setCustomName(player.getName() + "'s " + GetName());
//Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, mount);
}
public void Disable(Player player)
{
SingleEntityMountData<Slime> mount = _active.remove(player);
if (mount != null)
{
mount.remove();
//Inform
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + "."));
Manager.removeActive(player);
}
}
@EventHandler
public void interactMount(PlayerInteractEntityEvent event)
{
if (event.getRightClicked() == null)
return;
if (!GetActive().containsKey(event.getPlayer()))
return;
if(!GetActive().get(event.getPlayer()).ownsMount(event.getPlayer()))
return;
SingleEntityMountData<Slime> data = GetActive().get(event.getPlayer());
if(data == null) return;
if(!data.ownsMount(event.getPlayer())) return;
if(!data.isPartOfMount(event.getRightClicked())) return;
event.getPlayer().leaveVehicle();
event.getPlayer().eject();
event.getRightClicked().setPassenger(event.getPlayer());
}
@EventHandler
public void target(EntityTargetEvent event)
{
if (!GetActive().containsKey(event.getTarget()))
return;
if (!GetActive().get(event.getTarget()).equals(event.getEntity()))
event.setCancelled(true);
}
@EventHandler
public void updateBounce(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
//Bounce
for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null)
{
UtilEnt.setFakeHead(slime, false);
continue;
}
if (!UtilEnt.isGrounded(slime))
continue;
if (!(slime.getPassenger() instanceof Player))
continue;
Player player = (Player)slime.getPassenger();
if (!Recharge.Instance.use(player, GetName(), 200, false, false))
continue;
Vector dir = slime.getPassenger().getLocation().getDirection();
UtilAction.velocity(slime, dir, 1, true, 0, 0.4, 1, true);
UtilEnt.CreatureForceLook(slime, 0, UtilAlg.GetYaw(dir));
slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_WALK, 1f, 0.75f);
}
//Collide
for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null)
continue;
if (!(slime.getPassenger() instanceof Player))
continue;
Player player = (Player)slime.getPassenger();
if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue;
for (SingleEntityMountData<Slime> otherSlime : GetActive().values())
{
Slime other = otherSlime.getEntity();
if (other.equals(slime))
continue;
if (other.getPassenger() == null)
continue;
if (!(other.getPassenger() instanceof Player))
continue;
Player otherPlayer = (Player)other.getPassenger();
if (!Recharge.Instance.usable(otherPlayer, GetName() + " Collide"))
continue;
//Collide
if (UtilMath.offset(slime, other) > 2)
continue;
Recharge.Instance.useForce(player, GetName() + " Collide", 500);
Recharge.Instance.useForce(otherPlayer, GetName() + " Collide", 500);
UtilAction.velocity(slime, UtilAlg.getTrajectory(other, slime), 1.2, false, 0, 0.8, 10, true);
UtilAction.velocity(other, UtilAlg.getTrajectory(slime, other), 1.2, false, 0, 0.8, 10, true);
slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_ATTACK, 1f, 0.5f);
slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_WALK, 1f, 0.5f);
other.getWorld().playSound(other.getLocation(), Sound.SLIME_WALK, 1f, 0.5f);
slime.playEffect(EntityEffect.HURT);
other.playEffect(EntityEffect.HURT);
}
}
}
}

View File

@ -0,0 +1,10 @@
package mineplex.core.noteblock;
import org.bukkit.entity.Player;
public interface INoteVerifier
{
public boolean shouldPlay(Player player);
}

View File

@ -0,0 +1,131 @@
package mineplex.core.noteblock;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
/**
* Information about the NBS Format was taken from
* http://www.stuffbydavid.com/mcnbs/format
*/
public class NBSReader
{
public static NoteSong loadSong(String fileName) throws FileNotFoundException
{
return loadSong(new DataInputStream(new FileInputStream(new File(fileName))));
}
public static NoteSong loadSong(DataInputStream stream)
{
try
{
// Header Information
short length = readShort(stream);
short height = readShort(stream);
String name = readString(stream);
String author = readString(stream);
String originalAuthor = readString(stream);
String description = readString(stream);
short tempo = readShort(stream); // Tempo multiplied by 1000
boolean autosave = stream.readBoolean();
byte autosaveDuration = stream.readByte();
byte timeSignature = stream.readByte();
int minutesSpent = readInt(stream);
int leftClicks = readInt(stream);
int rightClicks = readInt(stream);
int blocksAdded = readInt(stream);
int blocksRemoved = readInt(stream);
String midiFileName = readString(stream);
HashMap<Integer, NoteLayer> layerMap = new HashMap<Integer, NoteLayer>();
// Note Block Information
int tick = -1;
int jumps = 0;
while (true)
{
jumps = readShort(stream);
if (jumps == 0)
break;
tick += jumps;
int layer = -1;
while (true)
{
jumps = readShort(stream);
if (jumps == 0)
break;
layer += jumps;
byte instrument = stream.readByte();
byte key = stream.readByte();
Note note = new Note(instrument, key);
NoteLayer noteLayer = layerMap.get(layer);
if (noteLayer == null)
{
noteLayer = new NoteLayer();
layerMap.put(layer, noteLayer);
}
noteLayer.setNote(tick, note);
}
}
// Layer Information
for (int i = 0; i < height; i++)
{
NoteLayer layer = layerMap.get(i);
if (layer != null)
{
layer.setName(readString(stream));
layer.setVolume(stream.readByte());
}
}
System.out.println("[NBSReader] Successfully loaded song " + name + "");
System.out.println("Tempo: " + tempo);
return new NoteSong(length, height, name, tempo, timeSignature, layerMap);
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
private static int readInt(DataInputStream stream) throws IOException
{
// For some reason the bytes are in reverse order from stream.readInt()
int ch1 = stream.read();
int ch2 = stream.read();
int ch3 = stream.read();
int ch4 = stream.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + ch1);
}
private static short readShort(DataInputStream stream) throws IOException
{
// For some reason the bytes are in reverse order from stream.readShort()
int ch1 = stream.read();
int ch2 = stream.read();
if ((ch1 | ch2) < 0)
throw new EOFException();
return (short)((ch2 << 8) + ch1);
}
private static String readString(DataInputStream stream) throws IOException
{
int length = readInt(stream);
char[] string = new char[length];
for (int i = 0; i < length; i++)
{
string[i] = (char) stream.readByte();
}
return new String(string);
}
}

View File

@ -0,0 +1,26 @@
package mineplex.core.noteblock;
/**
* Represents a single note to be played
*/
public class Note
{
private byte _instrument;
private byte _note;
public Note(byte instrument, byte note)
{
_instrument = instrument;
_note = note;
}
public byte getInstrument()
{
return _instrument;
}
public byte getNote()
{
return _note;
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.noteblock;
import java.util.HashMap;
/**
* Represents a layer of notes in Note Block Studio
*/
public class NoteLayer
{
private HashMap<Integer, Note> _noteMap; // Notes indexed by ticks
private int _volume; // Volume as a percentage 1-100
private String _name;
public NoteLayer()
{
_noteMap = new HashMap<Integer, Note>();
_volume = 100;
_name = "";
}
public int getVolume()
{
return _volume;
}
public void setVolume(int volume)
{
_volume = volume;
}
public String getName()
{
return _name;
}
public void setName(String name)
{
_name = name;
}
public void setNote(int ticks, Note note)
{
_noteMap.put(ticks, note);
}
public Note getNote(int ticks)
{
return _noteMap.get(ticks);
}
}

View File

@ -0,0 +1,104 @@
package mineplex.core.noteblock;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilServer;
import mineplex.core.noteblock.event.SongFinishEvent;
import mineplex.core.noteblock.event.SongStartEvent;
public class NotePlayer
{
private final JavaPlugin _plugin;
private final NoteSong _song;
private final INoteVerifier _verifier;
private final long _sleepMs;
private volatile float _volumeMult;
private volatile boolean _loop;
private volatile int _tick;
private volatile boolean _finished;
public NotePlayer(JavaPlugin plugin, NoteSong song, INoteVerifier verifier, float volumeMult, boolean loop)
{
_plugin = plugin;
_song = song;
_verifier = verifier;
_sleepMs = (long) (1000 / (song.getTempo() / 100D));
_loop = loop;
_tick = 0;
_volumeMult = volumeMult;
_finished = false;
startThread();
SongStartEvent event = new SongStartEvent(_song);
_plugin.getServer().getPluginManager().callEvent(event);
}
private void startThread()
{
Thread thread = new Thread(() -> {
while (!_finished)
{
_tick++;
if (_tick > _song.getLength())
{
if (_loop)
{
_tick = 1;
}
else
{
_finished = true;
_plugin.getServer().getScheduler().runTask(_plugin, () -> {
SongFinishEvent event = new SongFinishEvent(_song);
_plugin.getServer().getPluginManager().callEvent(event);
});
return;
}
}
playTick(_tick);
try
{
Thread.sleep(_sleepMs);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
});
thread.start();
}
private void playNote(Note note, float volume, Collection<? extends Player> players)
{
players.stream().filter(_verifier::shouldPlay).forEach((player) ->
player.playSound(player.getEyeLocation(), UtilNote.getInstrumentSound(note.getInstrument()), volume, (float) UtilNote.getPitch(note.getNote() - 33)));
}
private void playTick(int tick)
{
Collection<? extends Player> players = UtilServer.getPlayersCollection();
float volume = _volumeMult * 1F;
_song.getLayers().stream().map(layer -> layer.getNote(tick)).filter(Objects::nonNull).forEach((note) -> playNote(note, volume, players));
}
public void cancel()
{
_finished = true;
}
}

View File

@ -0,0 +1,57 @@
package mineplex.core.noteblock;
import java.util.Collection;
import java.util.HashMap;
public class NoteSong
{
// Song Data
private short _length;
private short _height;
private String _name;
private short _tempo;
private byte _timeSignature;
// Layer Data
private HashMap<Integer, NoteLayer> _layerMap;
public NoteSong(short length, short height, String name, short tempo, byte timeSignature, HashMap<Integer, NoteLayer> layerMap)
{
_length = length;
_height = height;
_name = name;
_tempo = tempo;
_timeSignature = timeSignature;
_layerMap = layerMap;
}
public short getLength()
{
return _length;
}
public short getHeight()
{
return _height;
}
public String getName()
{
return _name;
}
public short getTempo()
{
return _tempo;
}
public byte getTimeSignature()
{
return _timeSignature;
}
public Collection<NoteLayer> getLayers()
{
return _layerMap.values();
}
}

View File

@ -0,0 +1,42 @@
package mineplex.core.noteblock;
import org.bukkit.Sound;
/**
* See http://minecraft.gamepedia.com/Note_Block for information about pitches
*/
public class UtilNote
{
private static final double[] PITCH = { 0.5, 0.53, 0.56, 0.6, 0.63, 0.67, 0.7, 0.76, 0.8, 0.84, 0.9, 0.94, 1.0,
1.06, 1.12, 1.18, 1.26, 1.34, 1.42, 1.5, 1.6, 1.68, 1.78, 1.88, 2.0 };
public static Sound getInstrumentSound(byte instrument)
{
switch (instrument)
{
case 0:
return Sound.NOTE_PIANO;
case 1:
return Sound.NOTE_BASS_GUITAR;
case 2:
return Sound.NOTE_BASS_DRUM;
case 3:
return Sound.NOTE_SNARE_DRUM;
case 4:
return Sound.NOTE_STICKS;
default:
return Sound.NOTE_PIANO;
}
}
public static double getPitch(int note)
{
if (note >= 0 && note < PITCH.length)
{
return PITCH[note];
}
return 0.0;
}
}

View File

@ -0,0 +1,25 @@
package mineplex.core.noteblock.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.noteblock.NoteSong;
public class SongFinishEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { return handlers; }
public HandlerList getHandlers() { return handlers; }
private NoteSong _song;
public SongFinishEvent(NoteSong song)
{
_song = song;
}
public NoteSong getSong()
{
return _song;
}
}

View File

@ -0,0 +1,25 @@
package mineplex.core.noteblock.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.noteblock.NoteSong;
public class SongStartEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { return handlers; }
public HandlerList getHandlers() { return handlers; }
private NoteSong _song;
public SongStartEvent(NoteSong song)
{
_song = song;
}
public NoteSong getSong()
{
return _song;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.notifier;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -12,14 +13,16 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class NotificationManager extends MiniPlugin
{
private boolean _enabled = false;
private boolean _enabled = true;
private CoreClientManager _clientManager;
private PreferencesManager _preferencesManager;
private String _summerLine =
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
@ -29,11 +32,12 @@ public class NotificationManager extends MiniPlugin
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "";
public NotificationManager(JavaPlugin plugin, CoreClientManager client)
public NotificationManager(JavaPlugin plugin, CoreClientManager client, PreferencesManager preferencesManager)
{
super("Notification Manager", plugin);
_clientManager = client;
_preferencesManager = preferencesManager;
}
@EventHandler
@ -48,8 +52,25 @@ public class NotificationManager extends MiniPlugin
// if (event.getType() == UpdateType.MIN_16)
// sale();
if (event.getType() == UpdateType.MIN_08)
christmasSale();
}
private void christmasSale()
{
for (Player player : UtilServer.getPlayers())
{
if (!_preferencesManager.Get(player).DisableAds)
{
player.sendMessage(C.cWhite + " ");
player.sendMessage(C.cRedB + " MASSIVE WINTER SALE");
player.sendMessage(C.cWhiteB + " 50% OFF ALL RANKS");
player.sendMessage(" " + C.cGreen + C.Line + "www.mineplex.com/shop");
player.sendMessage(C.cWhite + " ");
}
}
}
private void sale()
{
for (Player player : UtilServer.getPlayers())

View File

@ -84,19 +84,6 @@ public class ServerCommand extends CommandBase<Portal>
else
deniedAccess = true;
}
else if (servUp.contains("CLANS-"))
{
if (playerRank.has(Rank.MODERATOR))
{
Plugin.sendPlayerToServer(player, args[0]);
}
else
{
UtilPlayer.message(player,
F.main(Plugin.getName(), C.cRed + "You must join clans through the hub! Join " + C.cGold + "ClansHub-1"
+ C.cRed + "!"));
}
}
else
{
Plugin.sendPlayerToServer(player, args[0]);

View File

@ -136,6 +136,6 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
}
}

View File

@ -24,7 +24,7 @@ public class PreferencesRepository extends RepositoryBase
// DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL
// NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ? WHERE uuid=?;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ? WHERE uuid=?;";
public PreferencesRepository(JavaPlugin plugin)
{
@ -61,8 +61,10 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
System.out.println(">> " + entry.getValue().ClanTips);
preparedStatement.setString(14, entry.getKey());
preparedStatement.setString(16, entry.getKey());
preparedStatement.addBatch();
}
@ -89,8 +91,10 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
System.out.println(">> " + entry.getValue().ClanTips);
preparedStatement.setString(14, entry.getKey());
preparedStatement.setString(16, entry.getKey());
preparedStatement.execute();
}
@ -122,6 +126,8 @@ public class PreferencesRepository extends RepositoryBase
preferences.PendingFriendRequests = resultSet.getBoolean(11);
preferences.friendDisplayInventoryUI = resultSet.getBoolean(12);
preferences.ClanTips = resultSet.getBoolean(13);
preferences.HubMusic = resultSet.getBoolean(14);
preferences.DisableAds = resultSet.getBoolean(15);
System.out.println("<< " + resultSet.getBoolean(13));
}

View File

@ -16,4 +16,6 @@ public class UserPreferences
public boolean PendingFriendRequests = true;
public boolean friendDisplayInventoryUI = true;
public boolean ClanTips = true;
public volatile boolean HubMusic = true;
public boolean DisableAds = false;
}

View File

@ -189,6 +189,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
public boolean preferencesChanged()
{
return _hubInvisibilityToggled || _macReportsToggled || _hubInvisibilityToggled || _hubForcefieldToggled;
return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled;
}
}

View File

@ -25,6 +25,8 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
private IButton _toggleHubPartyRequests;
private IButton _togglePendingFriendRequests;
private IButton _toggleClanTips;
private IButton _toggleHubMusic;
private IButton _toggleDisableAds;
private boolean _hubGamesToggled;
private boolean _hubPlayersToggled;
@ -33,6 +35,8 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
private boolean _hubPartyRequestsToggled;
private boolean _pendingFriendRequestsToggled;
private boolean _clanTipsToggled;
private boolean _hubMusicToggled;
private boolean _disableAdsToggled;
private ExclusivePreferencesShop _exclusiveShop;
@ -109,15 +113,48 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
togglePendingFriendRequests(player);
}
};
_toggleHubMusic = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubMusic(player);
}
};
_toggleDisableAds = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleDisableAds(player);
}
};
}
private void toggleHubMusic(Player player)
{
getPlugin().Get(player).HubMusic = !getPlugin().Get(player).HubMusic;
_hubMusicToggled = !_hubMusicToggled;
buildPage();
}
private void toggleDisableAds(Player player)
{
getPlugin().Get(player).DisableAds = !getPlugin().Get(player).DisableAds;
_disableAdsToggled = !_disableAdsToggled;
buildPage();
}
private void toggleHubPartyRequests(Player player)
{
getPlugin().Get(player).PartyRequests = !getPlugin().Get(player).PartyRequests;
_hubPartyRequestsToggled = !_hubPartyRequestsToggled;
buildPage();
}
private void togglePendingFriendRequests(Player player)
{
getPlugin().Get(player).PendingFriendRequests = !getPlugin().Get(player).PendingFriendRequests;
@ -179,8 +216,9 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
UserPreferences userPreferences = getPlugin().Get(getPlayer());
Rank rank = getClientManager().Get(getPlayer()).GetRank();
int[] indices = UtilUI.getIndicesFor(7, 0, 2);
int amount = rank.has(Rank.ULTRA) ? 9 : 8;
int[] indices = UtilUI.getIndicesFor(amount, 0, 2);
buildPreference(indices[0], Material.FIREBALL, "Hub Player Stacker", userPreferences.HubGames, _toggleHubGames);
buildPreference(indices[1], Material.EYE_OF_ENDER, "Hub Player Visibility", userPreferences.ShowPlayers, _toggleHubPlayers);
@ -189,6 +227,9 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
buildPreference(indices[4], Material.SKULL_ITEM, (byte) 3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests);
buildPreference(indices[5], Material.RED_ROSE, "Show Pending Friend Requests", userPreferences.PendingFriendRequests, _togglePendingFriendRequests);
buildPreference(indices[6], Material.IRON_SWORD, "Show Clan Tips", userPreferences.ClanTips, _toggleClanTips);
buildPreference(indices[7], Material.NOTE_BLOCK, "Hub Music", userPreferences.HubMusic, _toggleHubMusic);
if (rank.has(Rank.ULTRA))
buildPreference(indices[8], Material.BARRIER, "Disable Ads", userPreferences.DisableAds, _toggleDisableAds);
if (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)
{
@ -219,6 +260,6 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
public boolean preferencesChanged()
{
return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _pendingFriendRequestsToggled || _clanTipsToggled;
return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _pendingFriendRequestsToggled || _clanTipsToggled || _hubMusicToggled || _disableAdsToggled;
}
}

View File

@ -106,6 +106,10 @@ public class PlayerScoreboard
continue;
}
// Ignore extra lines
if (i >= _teamNames.length)
continue;
//Update
Team team = _scoreboard.getTeam(_teamNames[i]);
if (team == null)

View File

@ -91,41 +91,14 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, newValue - value, newValue));
// Verify stat is in our local cache, if not add it remotely.
if (!_stats.containsKey(statName))
registerNewStat(statName, new Runnable()
{
runAsync(new Runnable()
@Override
public void run()
{
public void run()
{
synchronized (_statSync)
{
// If many players come in for a new stat, when the first add finishes the others are queued to add again
// This makes a second check for the stat name (already added before lock was released)
// Then it pops into queue and forgets adding the new stat to db.
if (_stats.containsKey(statName))
{
addToQueue(statName, player, value);
return;
}
_repository.addStat(statName);
_stats.clear();
for (Stat stat : _repository.retrieveStats())
{
_stats.put(stat.Name, stat.Id);
}
addToQueue(statName, player, value);
}
}
});
}
else
{
addToQueue(statName, player, value);
}
addToQueue(statName, player, value);
}
});
}
private void addToQueue(String statName, Player player, long value)
@ -192,23 +165,51 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
public boolean incrementStat(final int accountId, final String statName, final long value)
{
if (_stats.containsKey(statName))
return false;
final NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
uploadQueue.get(accountId).put(_stats.get(statName), value);
runAsync(new Runnable()
// This will register a new stat if we don't have one, otherwise it will just run the callback
registerNewStat(statName, new Runnable()
{
@Override
public void run()
{
final NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
uploadQueue.get(accountId).put(_stats.get(statName), value);
_repository.saveStats(uploadQueue);
}
});
return true;
}
private void registerNewStat(final String statName, final Runnable callback)
{
runAsync(new Runnable()
{
public void run()
{
synchronized (_statSync)
{
if (_stats.containsKey(statName))
{
if (callback != null) callback.run();
return;
}
_repository.addStat(statName);
_stats.clear();
for (Stat stat : _repository.retrieveStats())
{
_stats.put(stat.Name, stat.Id);
}
if (callback != null) callback.run();
}
}
});
}
public int getStatId(String statName)
{

View File

@ -32,7 +32,7 @@ public class GiveawayMessageHandler implements CommandCallback
String playerName = message.getPlayerName();
int count = message.getTitanCount();
String countString = count + UtilTime.getDayOfMonthSuffix(count);
String chatMessage = C.cRed + playerName + C.cWhite + " found Titan in a " + C.cRed + "Flaming Pumpkin";
String chatMessage = C.cRed + playerName + C.cWhite + " found Titan in a " + C.cRed + "Christmas Present";
UtilTextMiddle.display(C.cDRed + C.Bold + "TITAN", chatMessage, 20, 80, 20, UtilServer.getPlayers());
World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0);
LightFlicker lightFlicker = new LightFlicker(world);

View File

@ -16,18 +16,20 @@ public class TitanChestGiveawayHandler implements CommandCallback
private ServerStatusManager _statusManager;
private long _lastTimer;
private boolean _enabled;
public TitanChestGiveawayHandler(ServerStatusManager statusManager)
{
_statusManager = statusManager;
_lastTimer = 0;
_enabled = false;
}
@Override
public void run(ServerCommand command)
{
if (command instanceof TitanChestGiveawayMessage)
if (command instanceof TitanChestGiveawayMessage && _enabled)
{
TitanChestGiveawayMessage chestCommand = ((TitanChestGiveawayMessage) command);
if (chestCommand.getServer().equals(_statusManager.getCurrentServerName()) || System.currentTimeMillis() >= _lastTimer + COOLDOWN)

View File

@ -49,7 +49,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Clans extends JavaPlugin
{
public static final String VERSION = "0.16";
public static final String VERSION = "0.17b";
private String WEB_CONFIG = "webServer";
// Modules

View File

@ -462,7 +462,7 @@ public class ClanInfo
public boolean isOnline()
{
return isOnlineNow() || System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
return isOnlineNow();// || System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
}
public String getProtected()

View File

@ -17,13 +17,15 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.event.ClanDeleteEvent;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClanLeaveEvent;
import mineplex.game.clans.clans.event.ClanSetHomeEvent;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
import mineplex.game.clans.core.war.ClanWarData;
import mineplex.game.clans.core.repository.ClanRepository;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.core.war.ClanWarData;
public class ClansDataAccessLayer
{
@ -201,6 +203,15 @@ public class ClansDataAccessLayer
public void join(final ClanInfo clan, final Player player, final ClanRole role, final Callback<Boolean> callback)
{
ClanJoinEvent event = new ClanJoinEvent(clan, player);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
runAsync(new Runnable()
{
@Override
@ -259,6 +270,15 @@ public class ClansDataAccessLayer
{
if (clan == null) return;
ClanLeaveEvent event = new ClanLeaveEvent(clan, clansPlayer);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
runAsync(new Runnable()
{
@Override
@ -636,6 +656,10 @@ public class ClansDataAccessLayer
{
final Timestamp currentTime = new Timestamp(System.currentTimeMillis());
final ClanWarData war = new ClanWarData(clanA.getName(), clanB.getName(), score, currentTime, currentTime, 0);
// Memory
clanA.addWar(war);
clanB.addWar(war);
runAsync(new Runnable()
{
@ -649,10 +673,6 @@ public class ClansDataAccessLayer
@Override
public void run()
{
// Memory
clanA.addWar(war);
clanB.addWar(war);
_manager.log("Initiator war for [" + clanA.getName() + "] against [" + clanB.getName() + "].");
if (warCallback != null) warCallback.run(war);

View File

@ -66,6 +66,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.claimview.ClaimVisualizer;
import mineplex.game.clans.clans.commands.ClanManagementCommand;
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
import mineplex.game.clans.clans.commands.ClansChatCommand;
@ -304,6 +305,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
loadClan(token);
}
// new ClaimVisualizer(plugin, this);
// RedisDataRepository(ConnectionData writeConn, ConnectionData
// readConn, Region region, Class<T> elementType, String elementLabel)
// Initialize default region factions and territory
@ -672,7 +675,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
if (clan == null)
{
event.setFormat(rank + C.cYellow + "%1$s " + C.cWhite + "%2$s");
System.out.println(_clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) ? C.cRed + "Creative " : " ") + event.getMessage());
System.out.println(_clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage());
return;
}
@ -692,7 +695,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
String message = event.getMessage();
message = _chat.getFilteredMessage(event.getPlayer(), message);
ClanRelation rel = _clanUtility.rel(clan, otherClan);
String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) ? C.cRed + "Creative " : " ") + C.cWhite + message;
String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message;
other.sendMessage(formatted);
}
}

View File

@ -717,11 +717,11 @@ public class ClansUtility
return false;
}
// if (clan.getEnergy() == 0)
// {
// Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land."));
// return false;
// }
if (clan.getEnergy() == 0)
{
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land."));
return false;
}
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk());
ClanInfo ownerClan = getOwner(caller.getLocation());
@ -740,11 +740,11 @@ public class ClansUtility
}
}
// if (clan.getClaims() >= clan.getClaimsMax())
// {
// Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory."));
// return false;
// }
if (clan.getClaims() >= clan.getClaimsMax())
{
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory."));
return false;
}
// Adjacent
boolean selfAdj = false;
@ -1084,7 +1084,7 @@ public class ClansUtility
}
// Event
PlayerUnClaimTerritoryEvent event = new PlayerUnClaimTerritoryEvent(caller, caller.getLocation().getChunk());
PlayerUnClaimTerritoryEvent event = new PlayerUnClaimTerritoryEvent(caller, caller.getLocation().getChunk(), ownerClan);
UtilServer.getServer().getPluginManager().callEvent(event);

View File

@ -0,0 +1,351 @@
package mineplex.game.clans.clans.claimview;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.claimview.commands.ClaimVisualizeCommand;
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.ClanLeaveEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
import net.minecraft.server.v1_8_R3.EnumDirection;
public class ClaimVisualizer extends MiniPlugin
{
private ClansManager _clansManager;
private List<String> _visualizing;
private NautHashMap<ClanInfo, NautHashMap<String, VisualizedChunkData>> _calculated;
public ClaimVisualizer(JavaPlugin plugin, ClansManager clansManager)
{
super("Claim Visualizer", plugin);
_clansManager = clansManager;
_visualizing = new ArrayList<>();
_calculated = new NautHashMap<>();
for (ClanInfo clan : _clansManager.getClanMap().values())
{
_calculated.put(clan, new NautHashMap<String, VisualizedChunkData>());
}
}
@Override
public void addCommands()
{
addCommand(new ClaimVisualizeCommand(this));
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOWER)
{
return;
}
_calculated.clear();
for (ClanInfo clan : _clansManager.getClanMap().values())
{
_calculated.put(clan, new NautHashMap<String, VisualizedChunkData>());
for (String serialized : clan.getClaimSet())
{
calculate(clan, serialized);
}
}
}
@EventHandler
public void runVisualization(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
for (String name : _visualizing)
{
Player player = Bukkit.getPlayer(name);
if (player != null && _clansManager.isInClan(player))
{
visualize(player);
}
}
}
private void visualize(Player player)
{
for (String serialized : _clansManager.getClan(player).getClaimSet())
{
if (!_calculated.get(_clansManager.getClan(player)).containsKey(serialized))
{
calculate(_clansManager.getClan(player), serialized);
}
}
draw(player, _calculated.get(_clansManager.getClan(player)).values());
}
private void draw(Player player, Collection<VisualizedChunkData> chunks)
{
for (VisualizedChunkData chunk : chunks)
{
if (!chunk.getChunk().getWorld().equals(player.getWorld()))
{
// return not break because a clan can't have claims in different worlds.
return;
}
if (UtilMath.offset2d(chunk.getChunk().getBlock(0, 0, 0).getLocation(), player.getLocation()) > 36)
{
break;
}
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
if (chunk.shouldDisplayEdge(x, z) && (z == 0 || z == 15 || x == 0 || x == 15))
{
Block block = chunk.getChunk().getBlock(x, 0, z);
UtilParticle.PlayParticle(ParticleType.RED_DUST,
new Location(
chunk.getChunk().getWorld(),
block.getX() + .5,
UtilBlock.getHighest(player.getWorld(), block.getX(), block.getZ()).getY() + .5,
block.getZ() + .5),
new Vector(0f, 0f, 0f), 0f, 1, ViewDist.NORMAL, player);
}
}
}
}
}
private void calculate(ClanInfo clan, String serialized)
{
Chunk chunk = UtilWorld.strToChunk(serialized);
List<EnumDirection> dirs = new ArrayList<>();
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1))))
{
dirs.add(EnumDirection.NORTH);
}
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ()))))
{
dirs.add(EnumDirection.EAST);
}
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() + 1))))
{
dirs.add(EnumDirection.SOUTH);
}
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ()))))
{
dirs.add(EnumDirection.WEST);
}
VisualizedChunkData cached = new VisualizedChunkData(chunk, dirs);
_calculated.get(clan).put(serialized, cached);
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
if (isVisualizing(event.getPlayer()))
{
disableVisualizer(event.getPlayer());
}
}
@EventHandler
public void onKick(PlayerKickEvent event)
{
if (isVisualizing(event.getPlayer()))
{
disableVisualizer(event.getPlayer());
}
}
@EventHandler
public void onLeave(ClanLeaveEvent event)
{
if (isVisualizing(event.getPlayer().getPlayerName()))
{
disableVisualizer(event.getPlayer().getPlayerName());
}
}
@EventHandler
public void onClanDisband(ClanDisbandedEvent event)
{
for (Player player : event.getClan().getOnlinePlayers())
{
if (isVisualizing(player))
{
disableVisualizer(player);
}
}
}
@EventHandler
public void update(ClanInfo clan)
{
_calculated.clear();
for (String serialized : clan.getClaimSet())
{
calculate(clan, serialized);
}
}
@EventHandler
public void onUnclaim(PlayerUnClaimTerritoryEvent event)
{
if (event.getClan().getClaimCount() == 1)
{
for (Player player : event.getClan().getOnlinePlayers())
{
if (isVisualizing(player))
{
disableVisualizer(player);
}
}
}
}
public boolean isVisualizing(Player player)
{
return _visualizing.contains(player.getName());
}
public boolean isVisualizing(String name)
{
return _visualizing.contains(name);
}
public void enableVisualizer(String name)
{
enableVisualizer(UtilServer.getServer().getPlayer(name));
}
public void disableVisualizer(String name)
{
disableVisualizer(UtilServer.getServer().getPlayer(name));
}
public void toggleVisualizer(Player player)
{
if (_visualizing.contains(player.getName()))
{
disableVisualizer(player);
}
else
{
enableVisualizer(player);
}
}
public void enableVisualizer(Player player)
{
if (player == null)
{
return;
}
if (!_clansManager.isInClan(player))
{
UtilPlayer.message(player, F.main("Clans", "You must be in a clan to visualize claims."));
return;
}
ClanInfo clan = _clansManager.getClan(player);
if (clan.getClaimCount() == 0)
{
UtilPlayer.message(player, F.main("Clans", "Your Clan does not have any claims!"));
return;
}
_visualizing.add(player.getName());
UtilPlayer.message(player, F.main("Clans", "You are now visualizing your claims."));
for (VisualizedChunkData chunk : _calculated.get(clan).values())
{
if (!chunk.getChunk().getWorld().equals(player.getWorld()))
{
// return not break because a clan can't have claims in different worlds.
return;
}
if (UtilMath.offset2d(chunk.getChunk().getBlock(0, 0, 0).getLocation(), player.getLocation()) > 36)
{
break;
}
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
if (chunk.shouldDisplayEdge(x, z) && (z == 0 || z == 15 || x == 0 || x == 15))
{
Block block = chunk.getChunk().getBlock(x, 0, z);
}
}
}
}
}
public void disableVisualizer(Player player)
{
if (player == null)
{
return;
}
if (!_visualizing.contains(player.getName()))
{
UtilPlayer.message(player, F.main("Clans", "You are anot visualizing your claims."));
return;
}
_visualizing.remove(player.getName());
UtilPlayer.message(player, F.main("Clans", "You are no longer visualizing your claims."));
}
}

View File

@ -0,0 +1,57 @@
package mineplex.game.clans.clans.claimview;
import java.util.List;
import org.bukkit.Chunk;
import net.minecraft.server.v1_8_R3.EnumDirection;
public class VisualizedChunkData
{
private List<EnumDirection> _displayableEdges;
private Chunk _chunk;
public long _start;
public VisualizedChunkData(Chunk chunk, List<EnumDirection> dir)
{
_chunk = chunk;
_displayableEdges = dir;
_start = System.currentTimeMillis();
}
public double getLife()
{
return (double) (System.currentTimeMillis() - _start);
}
public boolean shouldDisplayEdge(int x, int z)
{
if (z == 15 && !_displayableEdges.contains(EnumDirection.SOUTH))
{
return false;
}
if (x == 15 && !_displayableEdges.contains(EnumDirection.EAST))
{
return false;
}
if (x == 0 && !_displayableEdges.contains(EnumDirection.WEST))
{
return false;
}
if (z == 0 && !_displayableEdges.contains(EnumDirection.NORTH))
{
return false;
}
return true;
}
public Chunk getChunk()
{
return _chunk;
}
}

View File

@ -0,0 +1,22 @@
package mineplex.game.clans.clans.claimview.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.game.clans.clans.claimview.ClaimVisualizer;
public class ClaimVisualizeCommand extends CommandBase<ClaimVisualizer>
{
public ClaimVisualizeCommand(ClaimVisualizer plugin)
{
super(plugin, Rank.ALL, "showclaims");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.toggleVisualizer(caller);
}
}

View File

@ -38,7 +38,6 @@ import mineplex.game.clans.items.legendaries.WindBlade;
public class ClanManagementCommand extends CommandBase<ClansManager>
{
private ClansManager _clansManager;
public ClanManagementCommand(ClansManager plugin)

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.clans.commands;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
@ -24,6 +25,7 @@ import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.tutorials.Tutorial;
import mineplex.game.clans.tutorials.TutorialManager;
@ -382,6 +384,10 @@ public class ClansCommand extends CommandBase<ClansManager>
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!"));
return;
}
ClanJoinEvent event = new ClanJoinEvent(clan, caller);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) return;
// Task
Plugin.getClanDataAccess().join(clan, caller, ClanRole.RECRUIT, new Callback<Boolean>()

View File

@ -6,6 +6,8 @@ import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.tutorials.Tutorial;
@ -22,6 +24,12 @@ public class RestartTutCommand extends CommandBase<TutorialManager>
@Override
public void Execute(Player caller, String[] args)
{
if (ClansManager.getInstance().getClan(caller) != null)
{
UtilPlayer.message(caller, F.main("Tutorial", "You cannot restart the tutorial while in a clan"));
return;
}
if (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null
&& ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).isSafe(caller.getLocation()))
{
@ -43,7 +51,7 @@ public class RestartTutCommand extends CommandBase<TutorialManager>
}
else
{
TutorialManager.Instance.sendTutorialMsg(caller, "You must be in a safezone to restart the tutorial.");
TutorialManager.Instance.sendTutorialMsg(caller, F.main("Clans", "You must be in a Safe Zone to restart the tutorial."));
}
}
}

View File

@ -0,0 +1,56 @@
package mineplex.game.clans.clans.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansPlayer;
public class ClanLeaveEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private ClansPlayer _player;
private ClanInfo _clan;
private boolean _cancelled;
public ClanLeaveEvent(ClanInfo clan, ClansPlayer clansPlayer)
{
_player = clansPlayer;
_clan = clan;
}
public ClansPlayer getPlayer()
{
return _player;
}
public ClanInfo getClan()
{
return _clan;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public boolean isCancelled()
{
return _cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -5,19 +5,23 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
public class PlayerUnClaimTerritoryEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _unClaimer;
private Chunk _unClaimedChunk;
private ClanInfo _clan;
private boolean _cancelled;
public PlayerUnClaimTerritoryEvent(Player unClaimer, Chunk unClaimedChunk)
public PlayerUnClaimTerritoryEvent(Player unClaimer, Chunk unClaimedChunk, ClanInfo clan)
{
_unClaimer = unClaimer;
_unClaimedChunk = unClaimedChunk;
_clan = clan;
}
public Player getUnClaimer()
@ -35,6 +39,11 @@ public class PlayerUnClaimTerritoryEvent extends Event
_cancelled = cancelled;
}
public ClanInfo getClan()
{
return _clan;
}
public boolean isCancelled()
{
return _cancelled;

View File

@ -42,19 +42,17 @@ public class ClansScoreboardManager extends ScoreboardManager
private void init(TutorialManager tutorialManager)
{
setTitle(" MINEPLEX CLANS ");
setTitle("Clans Alpha " + Clans.VERSION);
ScoreboardData data = getData("default", true);
data.write(C.cGreen + "Clans Alpha " + Clans.VERSION);
data.writeEmpty();
data.writeElement(new ScoreboardElementClan(_clansManager));
data.writeElement(new ScoreboardElementPlayer(_clansManager));
data.writeElement(new ScoreboardElementPlayerCount(_clansManager));
data.writeElement(_worldEvent);
// data.writeElement(new ScoreboardElementPlayerCount(_clansManager));
data.writeElement(_warManager);
data.writeElement(_worldEvent);
for (Tutorial tutorial : tutorialManager.getTutorials().values())
{
data.writeElement(tutorial);

View File

@ -35,8 +35,7 @@ public class ScoreboardElementClan implements ScoreboardElement
// Energy
if (clanInfo.getEnergyCostPerMinute() > 0)
output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT));
output.add(C.cYellow + "Home " + C.cWhite + clanInfo.getBedStatusStr());
output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT));
}
else
{

View File

@ -27,10 +27,9 @@ public class ScoreboardElementPlayer implements ScoreboardElement
{
List<String> output = new ArrayList<String>();
output.add(C.cYellow + "Gold " + C.cWhite + manager.getDonation().Get(player).GetBalance(CurrencyType.Gold) + "");
output.add("");
String regionString = C.xWilderness + "Wilderness";
output.add(" ");
ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation());
if (claim != null)
{

View File

@ -29,7 +29,7 @@ public class ScoreboardElementPlayerCount implements ScoreboardElement
List<String> output = new ArrayList<String>();
output.add("");
output.add(C.cYellow + "Players Online " + UtilServer.getPlayers().length + "/100");
output.add(C.cYellow + "Players " + C.cWhite + UtilServer.getPlayers().length + "/100");
return output;
}

View File

@ -97,7 +97,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
{
for (WarInvasion invasion : invasions)
{
if (invasion.getInvaderClan().equals(playerClan))
if (invasion.getInvaderClan().equals(playerClan.getName()))
return true;
}
}
@ -125,15 +125,24 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
final ClanInfo killerClan = event.getKiller().getClan();
ClanWarData war = clan.getWarData(killerClan);
if (war != null && !war.isOnCooldown())
if (war != null)
{
if (war.isOnCooldown())
{
// Ignore!
return;
}
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
// War already exists
war.increment(killerClan.getName());
ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan);
_clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) +
clan.getName() + " " + C.Reset + "(" + killerClan.getFormattedWarPoints(clan) + C.Reset + ")"));
_clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) +
killerClan.getName() + " " + C.Reset + "(" + clan.getFormattedWarPoints(killerClan) + C.Reset + ")"));
war.increment(killerClan.getName());
checkWarComplete(war);
ClanInfo clanA = clan.getName().equals(war.getClanA()) ? clan : killerClan;
@ -142,9 +151,6 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
_clansManager.getScoreboard().refresh(killerClan);
_clansManager.getScoreboard().refresh(clan);
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
}
else
{
@ -155,14 +161,13 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
public void run(ClanWarData data)
{
ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan);
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
_clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) + clan.getName()));
_clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) + killerClan.getName()));
_clansManager.getScoreboard().refresh(killerClan);
_clansManager.getScoreboard().refresh(clan);
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
}
});
}
@ -271,7 +276,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
@EventHandler
public void onInvasionEnd(WarInvasionEndEvent event)
{
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvaderClan() + " has ended.")));
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvadedClan()) + " has ended."));
}
@ -301,13 +306,14 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
if (clan != null)
{
List<WarInvasion> invadedList = _invadedMap.get(clan);
List<WarInvasion> invaderList = _invaderMap.get(clan);
List<WarInvasion> invadedList = _invadedMap.get(clan.getName());
List<WarInvasion> invaderList = _invaderMap.get(clan.getName());
if (invaderList != null && !invaderList.isEmpty())
{
for (WarInvasion invasion : invaderList)
{
element.add(" ");
element.add(C.cPurpleB + "Invading");
element.add(" " + invasion.getInvadedClan());
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
@ -318,6 +324,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
{
for (WarInvasion invasion : invadedList)
{
element.add(" ");
element.add(C.cRedB + "Invaded");
element.add(" " + invasion.getInvaderClan());
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));

View File

@ -35,6 +35,7 @@ public class HeavyArrowsAttribute extends ItemAttribute
@Override
public void onAttack(CustomDamageEvent event)
{
event.AddKnockback("HeavyAttribute", _knockbackPercent);
double knockback = (_knockbackPercent / 100d) * 6;
event.AddKnockback("Heavy Attribute", knockback);
}
}

View File

@ -248,7 +248,7 @@ public class Spawn extends MiniPlugin
if (isInSpawn(player))
{
UtilPlayer.message(event.GetPlayer(), F.main("Safe Zone", "You cannot use " + F.skill(event.GetSkillName() + " in " + F.elem("Safe Zone") + ".")));
UtilPlayer.message(event.GetPlayer(), F.main("Safe Zone", "You cannot use " + F.skill(event.GetSkillName()) + " in " + F.elem("Safe Zone") + "."));
event.SetCancelled(true);
}
}

View File

@ -8,6 +8,7 @@ import java.util.Map;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -19,6 +20,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.jsonchat.ClickEvent;
@ -27,6 +29,8 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
@ -40,6 +44,7 @@ import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClanTipEvent;
import mineplex.game.clans.economy.GoldManager;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
@ -59,6 +64,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public static String SKIPPED_TASK = "tatatatata%sSkip";
public static String AllowedMessage = C.cGold + "TutorialAllowedMessage" + C.Reset;
public static String AllowedBypass = C.cBlue + "Tutorial>";
protected final TutorialManager _manager;
protected final GoldManager _goldManager;
@ -66,7 +72,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener
protected final TaskManager _taskManager;
protected final DonationManager _donationManager;
protected final LinkedHashMap<Integer, TutorialTask<?>> _tasks;
// protected final LinkedHashMap<Integer, TutorialTask<?>> _tasks;
private final ArrayList<TutorialTask<?>> _tasks;
protected final LinkedHashMap<String, TutorialTask<?>> _nameToTask;
protected final LinkedHashMap<String, TutorialClient> _inTutorial;
@ -89,7 +96,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_donationManager = donationManager;
_taskManager = taskManager;
_manager = manager;
_tasks = new LinkedHashMap<>();
_tasks = new ArrayList<TutorialTask<?>>();
_inTutorial = new LinkedHashMap<>();
_nameToTask = new LinkedHashMap<>();
@ -122,7 +129,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
lines.add(C.cAqua + "Tutorial");
for (final TutorialTask<?> task : _tasks.values())
for (final TutorialTask<?> task : _tasks)
{
if (get(player).CurrentTask.equals(task))
{
@ -142,10 +149,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return lines;
}
public TutorialTask<?> getTask(int index)
{
return _tasks.get(index);
}
protected void addTask(TutorialTask<?> task)
{
_tasks.put(_tasks.size() + 1, task);
_tasks.add(task);
_nameToTask.put(task.getTechnicalName(), task);
}
@ -158,6 +170,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return get(player).CurrentTask.getID() < task.getID();
}
private TutorialTask<?> getLastTask()
{
return _tasks.get(_tasks.size() - 1);
}
protected void finishTask(final Player player, final TutorialTask<?> task)
{
@ -175,8 +192,10 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{
public void run()
{
final TutorialTask<?> lastTask = getLastTask();
// Cycle to next task, or null if last task.
get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1);
get(player).CurrentTask = task.equals(lastTask) ? null : _tasks.get(task.getDataId() + 1);
System.out.println("Next Task: " + get(player).CurrentTask);
if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())))
{
@ -185,7 +204,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void run(final Boolean completed)
{
// If last task, end tutorial.
if (task.equals(_tasks.get(_tasks.size())))
if (task.equals(lastTask))
{
finishFor(player);
}
@ -196,7 +215,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{
public void run()
{
System.out.println("STARTING NEXT TASK!");
get(player).CurrentTask.startFor(player);
get(player).CurrentTaskStartTime = System.currentTimeMillis();
}
}, 30L);
}
@ -252,23 +273,22 @@ public abstract class Tutorial implements ScoreboardElement, Listener
private void finishFor(final Player player)
{
if (player.getOpenInventory() != null)
{
_inTutorial.get(player.getName()).QueuedFinish = true;
return;
}
// if (player.getOpenInventory() != null)
// {
// _inTutorial.get(player.getName()).QueuedFinish = true;
// return;
// }
_manager.finishTutorial(player);
_inTutorial.remove(player.getName());
UtilTextMiddle.display(C.cWhite + "Clans Tutorial", C.cGreen + "You have completed the Clans Tutorial!", 20, 20 * 3, 20);
onFinished(player);
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
public void run()
{
// Custom Finish Method (usually messages)
onFinished(player);
UtilTextMiddle.display(C.cWhite + "Clans Tutorial", C.cGreen + "You have completed the Clans Tutorial!", 20, 20 * 3, 20, player);
onFinishedDelay(player);
// Do Reward
if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName)))
{
@ -305,6 +325,25 @@ public abstract class Tutorial implements ScoreboardElement, Listener
}
}, player, String.format(TUTORIAL_REWARD_TASK, _technicalName));
}
else
{
UtilInv.remove(player, Material.IRON_AXE, (byte) 0, 1);
UtilInv.remove(player, Material.IRON_HELMET, (byte) 0, 1);
UtilInv.remove(player, Material.IRON_CHESTPLATE, (byte) 0, 1);
UtilInv.remove(player, Material.IRON_LEGGINGS, (byte) 0, 1);
UtilInv.remove(player, Material.IRON_BOOTS, (byte) 0, 1);
ItemStack[] armor = player.getInventory().getArmorContents();
for (int i = 0 ; i < armor.length; i++)
{
if (UtilItem.isIronProduct(armor[i]))
{
armor[i] = null;
}
}
player.getInventory().setArmorContents(armor);
}
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
@ -340,13 +379,17 @@ public abstract class Tutorial implements ScoreboardElement, Listener
}
}, 20 * 2);
}
}, 20 * 4);
}, 20 * 2);
}
// Implementation left to sub classes.
protected void onFinished(final Player player)
{
}
protected void onFinishedDelay(final Player player)
{
}
// Implementation left to sub classes.
protected void onBegin(final Player player)
@ -357,7 +400,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{
if (!_manager.isInTutorial(player))
{
_manager._playerTutorials.put(player.getName(), this);
_manager.setTutorial(player, this);
}
_inTutorial.put(player.getName(), new TutorialClient(player, this));
@ -380,8 +423,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void cancelFor(final Player player)
{
get(player).CurrentTask.cleanup(player);
get(player).CurrentTaskStartTime = -1;
_inTutorial.remove(player.getName());
_manager.finishTutorial(player);
if (_ghostMode)
{
for (Player other : UtilServer.getPlayers())
@ -402,11 +449,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return _inTutorial.containsKey(player);
}
public Map<Integer, TutorialTask<?>> getTasks()
{
return _tasks;
}
public boolean hasCompleted(final Player player)
{
return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName));
@ -419,9 +461,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void skip(final Player player)
{
new JsonMessage(
AllowedMessage
)
new JsonMessage("")
.extra(
F.main(
"Tutorial",
@ -435,9 +475,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener
.color("yellow")
.extra("!")
.color("gray")
.sendToPlayer(player);
new JsonMessage(
new JsonMessage("")
.extra(
F.main(
"Tutorial",
"Click "
@ -506,7 +548,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
}
}
get(player).CurrentTask.trySendDescription(player);
get(player).CurrentTask.trySendDescription(player, false);
}
}
}
@ -532,6 +574,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener
evt.setCancelled(true);
}
@EventHandler
public void onJoinClan(ClanJoinEvent event)
{
if (isInTutorial(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent evt)
{
@ -552,9 +603,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void cleanup(Player player)
{
if (get(player) != null && get(player).CurrentTask != null)
System.out.println("Cleaning up Player in " + getClass().getName());
if (get(player) != null && get(player).CurrentTask != null)
{
System.out.println("Cleaning up current task: " + get(player).CurrentTask.getClass().getName());
get(player).CurrentTask.cleanup(player);
}
System.out.println("removing from in tutorial");
_inTutorial.remove(player.getName());
}
}

View File

@ -11,15 +11,18 @@ public class TutorialClient
public long LastDescriptionSentTime = System.currentTimeMillis() - 3000;
public boolean InClanOnStart;
public boolean QueuedFinish;
public long CurrentTaskStartTime;
public TutorialClient(Player player, Tutorial tutorial)
{
Player = player;
CurrentTask = tutorial._tasks.get(1);
CurrentTask = tutorial.getTask(0);
CurrentTaskStartTime = System.currentTimeMillis();
InClanOnStart = tutorial._clansManager.isInClan(player);
/*
for (TutorialTask<?> task : tutorial._tasks.values())
{
if (TaskManager.Instance.hasCompletedTask(player, String.format(
@ -34,5 +37,6 @@ public class TutorialClient
}
}
}
*/
}
}

View File

@ -25,6 +25,7 @@ import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand;
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
public class TutorialManager extends MiniPlugin
@ -32,7 +33,7 @@ public class TutorialManager extends MiniPlugin
public static TutorialManager Instance;
private final Map<Class<? extends Tutorial>, Tutorial> _tutorials = new HashMap<>();
protected final Map<String, Tutorial> _playerTutorials = new HashMap<>();
private final Map<String, Tutorial> _playerTutorials = new HashMap<>();
private final TaskManager _taskManager;
@ -64,7 +65,7 @@ public class TutorialManager extends MiniPlugin
{
chat.a.a().remove(0);
}
else
else if (!chat.a.a().get(0).c().contains(Tutorial.AllowedBypass))
{
if (isInTutorial(packet.getPlayer()))
{
@ -138,10 +139,13 @@ public class TutorialManager extends MiniPlugin
@EventHandler
public void quit(PlayerQuitEvent event)
{
System.out.println("Player Quit. In Tutorial: " + isInTutorial(event.getPlayer()));
if (!isInTutorial(event.getPlayer()))
return;
getTutorial(event.getPlayer()).cleanup(event.getPlayer());
_playerTutorials.remove(event.getPlayer().getName());
}
public void sendTutorialMsg(Player player, String message)
@ -156,6 +160,16 @@ public class TutorialManager extends MiniPlugin
sendTutorialMsg(player, message);
}
}
public void finishTutorial(Player player)
{
_playerTutorials.remove(player.getName());
}
public void setTutorial(Player player, Tutorial tutorial)
{
_playerTutorials.put(player.getName(), tutorial);
}
public Tutorial getTutorial(final Player player)
{
@ -171,4 +185,72 @@ public class TutorialManager extends MiniPlugin
{
return _taskManager;
}
// Stolen from UtilTabTitle
private static class TextConverter
{
public static String convert(String text)
{
if (text == null || text.length() == 0)
{
return "\"\"";
}
char c;
int i;
int len = text.length();
StringBuilder sb = new StringBuilder(len + 4);
String t;
sb.append('"');
for (i = 0; i < len; i += 1)
{
c = text.charAt(i);
switch (c)
{
case '\\':
case '"':
sb.append('\\');
sb.append(c);
break;
case '/':
sb.append('\\');
sb.append(c);
break;
case '\b':
sb.append("\\b");
break;
case '\t':
sb.append("\\t");
break;
case '\n':
sb.append("\\n");
break;
case '\f':
sb.append("\\f");
break;
case '\r':
sb.append("\\r");
break;
default:
if (c < ' ')
{
t = "000" + Integer.toHexString(c);
sb.append("\\u").append(t.substring(t.length() - 4));
}
else
{
sb.append(c);
}
}
}
sb.append('"');
return sb.toString();
}
public static String setPlayerName(Player player, String text)
{
return text.replaceAll("(?i)\\{PLAYER\\}", player.getName());
}
}
}

View File

@ -1,13 +1,21 @@
package mineplex.game.clans.tutorials;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautArrayList;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
public class TutorialTask<T extends Tutorial> implements Listener
@ -22,6 +30,8 @@ public class TutorialTask<T extends Tutorial> implements Listener
protected String _description;
protected String _finishMessage;
protected String[] _subtasks;
protected Location _taskPos;
// How much time after the beginning the task/last teleport it should take to teleport back to _taskPos.
@ -29,7 +39,6 @@ public class TutorialTask<T extends Tutorial> implements Listener
protected long _descriptionWaitTime = 30000;
protected NautArrayList<String> _playersFinished = new NautArrayList<>();
protected NautArrayList<String> _inTask = new NautArrayList<>();
private long _lastTaskTp;
@ -55,7 +64,7 @@ public class TutorialTask<T extends Tutorial> implements Listener
{
_inTask.add(player.getName());
trySendDescription(player);
trySendDescription(player, true);
customStartFor(player);
@ -92,12 +101,41 @@ public class TutorialTask<T extends Tutorial> implements Listener
}
}
//@EventHandler
//todo: fix the multiline subtitles
public void displaySubtasks(UpdateEvent event)
{
if (!event.getType().equals(UpdateType.SEC))
{
return;
}
if (_subtasks == null || _subtasks.length == 0)
{
return;
}
Iterator<String> iterator = _inTask.iterator();
while (iterator.hasNext())
{
Player player = Bukkit.getPlayer(iterator.next());
if ((System.currentTimeMillis() - _tutorial.get(player).CurrentTaskStartTime) >= 15000)
{
if (isDoing(player))
{
UtilTextMiddle.display("", UtilText.arrayToString(_subtasks, "\n"), 1, 25, 25, player);
}
}
}
}
public boolean isDoing(Player player)
{
return _inTask != null && player != null && _inTask.contains(player.getName());
}
public void trySendDescription(Player player)
public void trySendDescription(Player player, boolean force)
{
if (!_tutorial.isInTutorial(player))
{
@ -111,19 +149,24 @@ public class TutorialTask<T extends Tutorial> implements Listener
return;
}
if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime())
if (force || System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime())
{
String description = _description;
ClanInfo clan = getClans().getClan(player);
if (clan != null) description = description.replace("(clan)", clan.getName());
description = description.replace("{", C.cAqua).replace("}", C.cWhite);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cYellowB + "Part " + _id + ": " + _displayName);
_tutorial._manager.sendTutorialMsg(player, C.cWhite + " " + _description.replace("{", C.cAqua).replace("}", C.cWhite));
_tutorial._manager.sendTutorialMsg(player, C.cYellowB + "Part " + (_id + 1) + ": " + _displayName);
_tutorial._manager.sendTutorialMsg(player, C.cWhite + " " + description);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilTextMiddle.display("", getDisplayName());
UtilTextMiddle.display("", getDisplayName(), player);
client.LastDescriptionSentTime = System.currentTimeMillis();
}
@ -169,30 +212,39 @@ public class TutorialTask<T extends Tutorial> implements Listener
{
return _tutorial._clansManager;
}
public int getID()
public int getDataId()
{
return _id;
}
public int getID()
{
return _id + 1;
}
public void finishFor(Player player)
{
customEndFor(player);
cleanup(player);
_tutorial.finishTask(player, this);
}
public void visibleFinish(Player player)
{
_inTask.remove(player.getName());
if (_finishMessage != null)
{
String finishMessage = _finishMessage;
ClanInfo clan = getClans().getClan(player);
if (clan != null) finishMessage = finishMessage.replace("(clan)", clan.getName());
finishMessage = finishMessage.replace("{", C.cAqua).replace("}", C.cWhite);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cWhite + _finishMessage.replace("{", C.cAqua).replace("}", C.cWhite));
_tutorial._manager.sendTutorialMsg(player, C.cWhite + finishMessage);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
}
@ -201,7 +253,6 @@ public class TutorialTask<T extends Tutorial> implements Listener
public void cleanup(Player player)
{
_inTask.remove(player.getName());
_playersFinished.remove(player.getName());
}
public long getDescriptionWaitTime()

View File

@ -21,7 +21,7 @@ public class TaskClaim extends TutorialTask<TutorialGettingStarted>
+ "Once claimed, only your Clan can break/place blocks here. "
+ "This is the perfect place to build a base and stash your items! "
+ "You can only claim in the Wilderness, and not next to other Clan's Territory. "
+ "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking}";
+ "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking} the Territory button. (Looks like a flag)";
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)

View File

@ -48,7 +48,14 @@ public class TaskCustomizeClass extends TutorialTask<TutorialGettingStarted>
if (clientclass != null && clientclass.GetSavingCustomBuild() != null && clientclass.GetSavingCustomBuild().AxeSkill != null)
{
finishFor(player);
iterator.remove();
}
}
}
@Override
public void cleanup(Player player)
{
// handled in onUpdate
}
}

View File

@ -25,18 +25,6 @@ public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
@Override
public void customStartFor(final Player player)
{
if (_tutorial.get(player).InClanOnStart)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getManager().getPlugin(), new Runnable(){
public void run()
{
if (isDoing(player))
{
finishFor(player);
}
}
}, 6 * 20);
}
}
@EventHandler
@ -46,6 +34,8 @@ public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
{
return;
}
System.out.println("COMPLETE DISBAND CLAN!");
finishFor(event.getDisbander());
}

View File

@ -29,6 +29,12 @@ public class TaskEquipClass extends TutorialTask<TutorialGettingStarted>
+ "Purchase Iron Armor from the PvP Shop. "
+ "Then put on your armor to equip the Knight Class.";
// _subtasks = new String[] {
// "Open the PvP Shop",
// "Buy Iron Armor Set",
// "Equip Iron Armor"
// };
_taskPos = new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f);
}
@ -56,6 +62,11 @@ public class TaskEquipClass extends TutorialTask<TutorialGettingStarted>
public void customStartFor(Player player)
{
_bought.put(player.getName(), new NautArrayList<Material>());
if (getClans().getClassManager().Get(player).GetGameClass() != null)
{
finishFor(player);
}
}
@EventHandler

View File

@ -57,12 +57,19 @@ public class TaskExploreShops extends TutorialTask<TutorialGettingStarted>
if (ClansManager.getInstance().getClan(event.getPlayer()).getEnergyPurchasable() == 0)
{
finishFor(event.getPlayer());
_inTask.remove(event.getPlayer().getName());
return;
}
event.setFree(true);
}
@Override
public void cleanup(Player player)
{
// handled in on update
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
@ -78,6 +85,7 @@ public class TaskExploreShops extends TutorialTask<TutorialGettingStarted>
if (ClansManager.getInstance().getClan(player).getEnergy() == ClansManager.getInstance().getClan(player).getEnergyMax())
{
finishFor(player);
iterator.remove();
}
}
}

View File

@ -6,6 +6,8 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.tutorials.TutorialTask;
@ -31,6 +33,7 @@ public class TaskLeaveSpawn extends TutorialTask<TutorialGettingStarted>
if (player.getLocation().getY() < 100)
{
finishFor(player);
_inTask.remove(player.getName());
}
}
@ -45,12 +48,20 @@ public class TaskLeaveSpawn extends TutorialTask<TutorialGettingStarted>
Iterator<String> iterator = _inTask.iterator();
while (iterator.hasNext())
{
Player player = Bukkit.getPlayer(iterator.next());
String playerName = iterator.next();
Player player = UtilPlayer.searchExact(playerName);
if (player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null)
if (player != null && player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null)
{
finishFor(player);
iterator.remove();
}
}
}
@Override
public void cleanup(Player player)
{
// We handle this in update() to avoid ConcurrentModificationException
}
}

View File

@ -34,7 +34,7 @@ public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
@Override
public void customStartFor(Player player)
{
player.getInventory().addItem(new ItemStack(Material.CARROT, 1));
player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 1));
}
@EventHandler
@ -45,7 +45,7 @@ public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
return;
}
if (!event.getItem().getType().equals(Material.CARROT))
if (!event.getItem().getType().equals(Material.CARROT_ITEM))
{
return;
}
@ -61,15 +61,12 @@ public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
return;
}
if (!ClansManager.getInstance().isInClan(event.getPlayer()))
{
return;
}
if (!event.getItem().getType().equals(Material.CARROT_ITEM))
{
return;
}
System.out.println("FINISH CARROT");
finishFor(event.getPlayer());
}

View File

@ -9,14 +9,18 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautArrayList;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilServer;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -49,7 +53,6 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
public void customStartFor(Player player)
{
_bought.put(player.getName(), new NautArrayList<Material>());
_teleported.put(player.getName(), false);
}
@Override
@ -70,7 +73,7 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
{
Player _player = Bukkit.getPlayer(iterator.next());
if (!_teleported.get(_player.getName()) && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING)
if (!_teleported.containsKey(_player.getName()) && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING)
{
_player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f));
_teleported.put(_player.getName(), true);
@ -78,6 +81,7 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
}
}
/*
@EventHandler
public void onAbilityUesd(SkillTriggerEvent event)
{
@ -88,6 +92,25 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
finishFor(event.GetPlayer());
}
*/
@EventHandler
public void onRightClick(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!isDoing(player))
return;
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
ItemStack item = player.getItemInHand();
if (item != null && item.getType() == Material.IRON_AXE)
{
finishFor(player);
}
}
}
@EventHandler
public void button(ClansShopAddButtonEvent event)

View File

@ -16,7 +16,7 @@ public class TaskViewClanDetails extends TutorialTask<TutorialGettingStarted>
_technicalName = "CommandClanX";
_description = "Now you can view information about your clan. "
+ "To do this type {/c [clan name]}! "
+ "To do this type {/c (clan)}! "
+ "You can also use any clan's name to get some information about them as well.";
}

View File

@ -25,7 +25,7 @@ public class TutorialGettingStarted extends Tutorial
// addTask(new TaskWelcome(this, 1));
int id = 0;
int id = -1;
addTask(new TaskCreateClan(this, ++id));
addTask(new TaskViewClanDetails(this, ++id));
addTask(new TaskLeaveSpawn(this, ++id));
@ -49,6 +49,13 @@ public class TutorialGettingStarted extends Tutorial
@Override
public void onFinished(final Player player)
{
player.resetPlayerTime();
player.teleport(Spawn.getEastSpawn());
}
@Override
protected void onFinishedDelay(Player player)
{
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_manager.sendTutorialMsg(player, C.cYellowB + "CONGRATULATIONS");
@ -56,11 +63,8 @@ public class TutorialGettingStarted extends Tutorial
_manager.sendTutorialMsg(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold");
_manager.sendTutorialMsg(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!");
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
player.resetPlayerTime();
player.teleport(Spawn.getEastSpawn());
}
@Override
public void onBegin(final Player player)
{

View File

@ -22,9 +22,7 @@ public class HubClient
public int DisplayLength = 16;
private int _lastGemCount = 0;
private int _lastCoinCount = 0;
public HubClient(String name)
{
ScoreboardString = " Welcome " + name + ", to the Mineplex Network!";
@ -133,14 +131,4 @@ public class HubClient
return display;
}
public void SetLastCoinCount(int coins)
{
_lastCoinCount = coins;
}
public int GetLastCoinCount()
{
return _lastCoinCount;
}
}

View File

@ -1,7 +1,13 @@
package mineplex.hub;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClient;
@ -21,6 +27,7 @@ import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.CosmeticManager;
@ -30,12 +37,17 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.message.PrivateMessageEvent;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.noteblock.INoteVerifier;
import mineplex.core.noteblock.NBSReader;
import mineplex.core.noteblock.NotePlayer;
import mineplex.core.noteblock.NoteSong;
import mineplex.core.noteblock.event.SongFinishEvent;
import mineplex.core.notifier.NotificationManager;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
@ -119,7 +131,7 @@ import org.bukkit.scoreboard.Scoreboard;
public class HubManager extends MiniClientPlugin<HubClient>
{
// Snowman!
public HubType Type = HubType.Normal;
public HubType Type = HubType.Christmas;
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;
@ -154,15 +166,18 @@ public class HubManager extends MiniClientPlugin<HubClient>
private HashMap<Player, Scoreboard> _scoreboards = new HashMap<Player, Scoreboard>();
private String _serverName = "";
private int _lastPlayerCount = 0;
private boolean _shuttingDown;
private HashMap<String, Long> _portalTime = new HashMap<String, Long>();
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>();
//Admin
private boolean _gadgetsEnabled = true;
// Christmas Songs
private Random _random = new Random();
private int _lastSong = 0;
// private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"};
private final ArrayList<NoteSong> _songs;
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, GiveawayManager giveawayManager)
{
@ -219,12 +234,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
_achievementManager.setGiveInterfaceItem(true);
_packetHandler = packetHandler;
new NotificationManager(getPlugin(), clientManager);
new NotificationManager(getPlugin(), clientManager, preferences);
new BotSpamManager(plugin, clientManager, punish);
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager);
// _halloweenManager = new HalloweenSpookinessManager(this);
@ -232,10 +246,70 @@ public class HubManager extends MiniClientPlugin<HubClient>
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
// new MailManager(_plugin, notificationManager);
_songs = new ArrayList<NoteSong>();
try
{
File songsFolder = new File("../../update/songs/");
if (songsFolder.exists())
{
File[] files = songsFolder.listFiles();
for (File file : files)
{
if (file.getName().endsWith(".nbs"))
{
System.out.println("Loading Song " + file.getPath());
NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(file)));
if (song != null)
{
_songs.add(song);
}
}
}
}
}
catch (FileNotFoundException e)
{
e.printStackTrace();
System.out.println("FAILED TO LOAD SONG!!");
}
playNextSong();
_serverName = getPlugin().getConfig().getString("serverstatus.name");
_serverName = _serverName.substring(0, Math.min(16, _serverName.length()));
}
private void playNextSong()
{
if (_songs.isEmpty())
return;
int index = (_lastSong + _random.nextInt(_songs.size() - 1)) % _songs.size();
NoteSong song = _songs.get(index);
if (song != null)
{
for (Player player : UtilServer.getPlayers())
{
if (_preferences.Get(player).HubMusic)
{
UtilTextBottom.display(C.cWhite + "Now Playing " + C.cYellow + song.getName(), player);
}
}
new NotePlayer(_plugin, song, new INoteVerifier()
{
@Override
public boolean shouldPlay(Player player)
{
return _preferences.Get(player).HubMusic;
}
}, 0.5F, false);
}
}
@Override
public void addCommands()
{
@ -267,50 +341,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
return true;
}
@EventHandler
public void SnowballPickup(BlockDamageEvent event)
{
if (Type != HubType.Christmas)
return;
if (event.getBlock().getType() != Material.SNOW)
return;
Player player = event.getPlayer();
_gadgetManager.RemoveItem(player);
player.getInventory().setItem(3, new ItemStack(Material.SNOW_BALL, 16));
}
@EventHandler
public void SnowballHit(CustomDamageEvent event)
{
if (Type != HubType.Christmas)
return;
Projectile proj = event.GetProjectile();
if (proj == null) return;
if (!(proj instanceof Snowball))
return;
event.SetCancelled("Snowball Cancel");
if (BumpDisabled(event.GetDamageeEntity()))
return;
if (BumpDisabled(event.GetDamagerEntity(true)))
return;
UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()),
0.4, false, 0, 0.2, 1, false);
//No Portal
SetPortalDelay(event.GetDamageeEntity());
}
@EventHandler
public void redirectStopCommand(PlayerCommandPreprocessEvent event)
{
@ -663,39 +693,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
if (_scoreboardTick != 0)
return;
// int bestPig = 0;
// for (Player player : UtilServer.getPlayers())
// {
// if (player.getVehicle() != null)
// continue;
//
// int count = 0;
//
// Entity ent = player;
// while (ent.getPassenger() != null)
// {
// ent = ent.getPassenger();
// count++;
// }
//
// if (count > bestPig)
// {
// _pigStacker = player.getName();
// bestPig = count;
// }
// }
// if (bestPig == 0)
// {
// _pigStacker = "0 - Nobody";
// }
// else
// {
// _pigStacker = bestPig + " - " + _pigStacker;
//
// if (_pigStacker.length() > 16)
// _pigStacker = _pigStacker.substring(0, 16);
// }
for (Player player : UtilServer.getPlayers())
{
//Dont Waste Time
@ -731,15 +728,14 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Space
obj.getScore(" ").setScore(line--);
//Coins
obj.getScore(C.cYellow + C.Bold + "Coins").setScore(line--);
//Players
obj.getScore(C.cYellow + C.Bold + "Players").setScore(line--);
// Remove Old
player.getScoreboard().resetScores(Get(player.getName()).GetLastCoinCount() + "");
// Add New
obj.getScore(GetDonation().Get(player.getName()).getCoins() + "").setScore(line--);
Get(player.getName()).SetLastCoinCount(GetDonation().Get(player.getName()).getCoins());
player.getScoreboard().resetScores(_lastPlayerCount + "");
_lastPlayerCount++;
obj.getScore(_lastPlayerCount + "").setScore(line--);
//Space
@ -913,12 +909,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
event.SetCancelled(true);
}
public boolean IsGadgetEnabled()
{
return _gadgetsEnabled;
}
public NewsManager GetNewsManager()
{
return _news;
@ -935,30 +925,15 @@ public class HubManager extends MiniClientPlugin<HubClient>
public void ToggleGadget(Player caller)
{
_gadgetsEnabled = !_gadgetsEnabled;
toggleGadget();
}
if (!_gadgetsEnabled)
{
GetMount().DisableAll();
GetGadget().DisableAll();
}
public void toggleGadget()
{
GetGadget().toggleGadgetEnabled();
for (Player player : UtilServer.getPlayers())
player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(_gadgetsEnabled ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled"));
}
@EventHandler
public void GadgetActivate(GadgetActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler
public void MountActivate(MountActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(GetGadget().isGadgetEnabled() ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled"));
}
public void addGameMode(Player caller, Player target)
@ -1030,4 +1005,20 @@ public class HubManager extends MiniClientPlugin<HubClient>
new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();;
}
@EventHandler
public void disableMusicChristmas(GadgetActivateEvent event)
{
if (event.getGadget() != null && event.getGadget().getGadgetType() == GadgetType.MusicDisc)
{
UtilPlayer.message(event.getPlayer(), F.main("Hub", "Music Discs are disabled right now!"));
event.setCancelled(true);
}
}
@EventHandler
public void onSongFinish(SongFinishEvent event)
{
playNextSong();
}
}

View File

@ -65,7 +65,7 @@ public class HubVisibilityManager extends MiniPlugin
{
boolean hideMe = Manager.GetTutorial().InTutorial(player) ||
UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 ||
Manager.getPreferences().Get(player).Invisibility ||
(Manager.getPreferences().Get(player).Invisibility && Manager.GetClients().Get(player).GetRank().has(Rank.MODERATOR)) ||
_hiddenPlayers.contains(player);
for (Player other : UtilServer.getPlayers())

View File

@ -258,7 +258,44 @@ public class NewsManager extends MiniPlugin
String text = "";
double healthPercent = 1;
if (Manager.Type == HubType.Halloween)
if (Manager.Type == HubType.Christmas)
{
_animationIndex = (_animationIndex + 1) % 40;
if (_animationIndex == 0) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 5" + C.cWhiteB + "0% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 1) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50" + C.cWhiteB + "% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 2) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% " + C.cWhiteB + "OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 3) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% O" + C.cWhiteB + "FF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 4) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OF" + C.cWhiteB + "F ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 5) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF " + C.cWhiteB + "ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 6) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF A" + C.cWhiteB + "LL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 7) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF AL" + C.cWhiteB + "L RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 8) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL " + C.cWhiteB + "RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 9) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL R" + C.cWhiteB + "ANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 10) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RA" + C.cWhiteB + "NKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 11) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RAN" + C.cWhiteB + "KS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 12) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANK" + C.cWhiteB + "S " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 13) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 14) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 15) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 16) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 17) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 18) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 19) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 20) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 21) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 22) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 23) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 24) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 25) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 26) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex >= 27)
text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " " + C.cWhiteB + "50% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
}
else if (Manager.Type == HubType.Halloween)
{
/**
* @author Mysticate

View File

@ -238,7 +238,6 @@ public class SoccerManager extends MiniPlugin
if (UtilAlg.inBoundingBox(_ball.getLocation(), _cornerRedGoalA, _cornerRedGoalB) &&
!UtilAlg.inBoundingBox(_ball.getLocation(), _cornerFieldA, _cornerFieldB))
{
_insideGoalTicks++;
if (_insideGoalTicks > 3)

View File

@ -14,12 +14,14 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerManager;
import mineplex.hub.server.ui.button.SelectBHButton;
import mineplex.hub.server.ui.button.SelectBLDButton;
import mineplex.hub.server.ui.button.SelectBRButton;
import mineplex.hub.server.ui.button.SelectCSButton;
import mineplex.hub.server.ui.button.SelectDMTButton;
import mineplex.hub.server.ui.button.SelectDOMButton;
import mineplex.hub.server.ui.button.SelectMINButton;
import mineplex.hub.server.ui.button.SelectMSButton;
import mineplex.hub.server.ui.button.SelectPLAYERButton;
import mineplex.hub.server.ui.button.SelectSGButton;
import mineplex.hub.server.ui.button.SelectSKYButton;
@ -193,9 +195,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
getButtonMap().put(8, new SelectWIZButton(this));
getButtonMap().put(18, new SelectCSButton(this));
// getButtonMap().put(20, new SelectBHButton(this));
getButtonMap().put(20, new SelectBHButton(this));
getButtonMap().put(22, new SelectSSMButton(this));
// getButtonMap().put(24, new SelectMSButton(this));
getButtonMap().put(24, new SelectMSButton(this));
getButtonMap().put(26, new SelectDMTButton(this));
getButtonMap().put(36, new SelectDOMButton(this));
getButtonMap().put(38, new SelectTDMButton(this));

View File

@ -0,0 +1,23 @@
package mineplex.hub.server.ui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import mineplex.hub.server.ui.ServerGameMenu;
public class SelectBHButton implements IButton
{
private ServerGameMenu _menu;
public SelectBHButton(ServerGameMenu menu)
{
_menu = menu;
}
@Override
public void onClick(Player player, ClickType clickType)
{
_menu.OpenBH(player);
}
}

View File

@ -0,0 +1,23 @@
package mineplex.hub.server.ui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import mineplex.hub.server.ui.ServerGameMenu;
public class SelectMSButton implements IButton
{
private ServerGameMenu _menu;
public SelectMSButton(ServerGameMenu menu)
{
_menu = menu;
}
@Override
public void onClick(Player player, ClickType clickType)
{
_menu.openMS(player);
}
}

View File

@ -39,6 +39,7 @@ public enum GameType
MineStrike("MineStrike"),
MineWare("MineWare"),
MilkCow("Milk the Cow"),
MonsterLeague("MonsterLeague"),
MonsterMaze("Monster Maze"),
Paintball("Super Paintball"),
Quiver("One in the Quiver"),

View File

@ -378,7 +378,7 @@ public class DamageManager extends MiniPlugin
event.GetDamageeEntity().playEffect(EntityEffect.HURT);
//Sticky Arrow
if (event.GetCause() == DamageCause.PROJECTILE)
if (event.GetCause() == DamageCause.PROJECTILE && event.GetProjectile() != null && event.GetProjectile() instanceof Arrow)
((CraftLivingEntity)event.GetDamageeEntity()).getHandle().o(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().bv() + 1);
//Knockback

View File

@ -4,14 +4,17 @@ package mineplex.serverdata.commands;
public class AnnouncementCommand extends ServerCommand
{
private boolean _displayTitle;
private String _rank;
private String _message;
public boolean getDisplayTitle() { return _displayTitle; }
public String getRank() { return _rank; }
public String getMessage() { return _message; }
public AnnouncementCommand(boolean displayTitle, String message)
public AnnouncementCommand(boolean displayTitle, String rank, String message)
{
_displayTitle = displayTitle;
_rank = rank;
_message = message;
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.ClassCombat"/>

View File

@ -1,14 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line
org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert

View File

@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
@ -58,6 +59,7 @@ import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.timing.TimingManager;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
@ -100,6 +102,7 @@ import nautilus.game.arcade.managers.GameSpectatorManager;
import nautilus.game.arcade.managers.GameStatManager;
import nautilus.game.arcade.managers.GameTournamentManager;
import nautilus.game.arcade.managers.GameWorldManager;
import nautilus.game.arcade.managers.HolidayManager;
import nautilus.game.arcade.managers.IdleManager;
import nautilus.game.arcade.managers.MiscManager;
import nautilus.game.arcade.shop.ArcadeShop;
@ -297,16 +300,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new MiscManager(this);
_hologramManager = hologramManager;
_idleManager = new IdleManager(this);
//TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
//new HolidayManager(this, titanGiveaway);
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
new HolidayManager(this, titanGiveaway);
// Game Addons
new CompassAddon(plugin, this);
new SoupAddon(plugin, this);
new TeamArmorAddon(plugin, this);
new NotificationManager(getPlugin(), clientManager);
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager);
//Champions Modules
@ -1236,6 +1237,25 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
}
@EventHandler
public void disableGadget(PlayerJoinEvent event)
{
updateGadgetEnabled();
}
@EventHandler
public void disableGadget(PlayerQuitEvent event)
{
updateGadgetEnabled();
}
private void updateGadgetEnabled()
{
// Disables gadgets if player count is greater than 40
int playerCount = UtilServer.getPlayers().length;
getCosmeticManager().getGadgetManager().setGadgetEnabled(playerCount <= 40);
}
/*public void saveBasicStats(final Game game)
{
if (!IsTournamentServer())

View File

@ -8,6 +8,7 @@ import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl;
import nautilus.game.arcade.game.games.barbarians.Barbarians;
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
import nautilus.game.arcade.game.games.bouncyballs.BouncyBalls;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.build.Build;
import nautilus.game.arcade.game.games.cards.Cards;
@ -35,6 +36,7 @@ import nautilus.game.arcade.game.games.micro.Micro;
import nautilus.game.arcade.game.games.milkcow.MilkCow;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
import nautilus.game.arcade.game.games.mineware.MineWare;
import nautilus.game.arcade.game.games.monsterleague.MonsterLeague;
import nautilus.game.arcade.game.games.monstermaze.MonsterMaze;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.paintball.Paintball;
@ -125,6 +127,9 @@ public enum GameType
Skywars(SoloSkywars.class, GameDisplay.Skywars),
SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false),
MonsterMaze(MonsterMaze.class, GameDisplay.MonsterMaze),
MonsterLeague(MonsterLeague.class, GameDisplay.MonsterLeague),
BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls),
Event(EventGame.class, GameDisplay.Event, new GameType[]{
GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build,

View File

@ -10,7 +10,7 @@ public class KitUnlockCommand extends CommandBase<ArcadeManager>
{
public KitUnlockCommand(ArcadeManager plugin)
{
super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.JNR_DEV}, new String[] {"youtube", "twitch", "kits"});
super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.YOUTUBE_SMALL, Rank.TWITCH, Rank.JNR_DEV}, new String[] {"youtube", "twitch", "kits"});
}
@Override

View File

@ -36,6 +36,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -1723,4 +1724,21 @@ public abstract class Game implements Listener
}
}
}
@EventHandler
public void debug(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().equals("/debugteams"))
{
for (GameTeam team : GetTeamList())
{
event.getPlayer().sendMessage(team.GetFormattedName());
for (Player player : team.GetPlayers(false))
{
event.getPlayer().sendMessage(player.getName() + ": " + team.IsAlive(player));
}
}
}
}
}

View File

@ -79,7 +79,7 @@ public class GameTeam
{
Host = host;
_displayName = name;
_displayName = null;
_name = name;
_color = color;
_spawns = spawns;
@ -178,7 +178,7 @@ public class GameTeam
{
_players.put(player, in ? PlayerState.IN : PlayerState.OUT);
UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + _displayName + " Team."));
UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + getDisplayName() + " Team."));
VisibilityManager.Instance.refreshPlayerToAll(player);
}
@ -192,7 +192,7 @@ public class GameTeam
other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name + _name.toUpperCase()).removePlayer(player);
other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
}
UtilPlayer.message(player, F.main("Team", _color + C.Bold + _displayName + " Team was disbanded."));
UtilPlayer.message(player, F.main("Team", _color + C.Bold + getDisplayName() + " Team was disbanded."));
}
_players.clear();
@ -323,6 +323,9 @@ public class GameTeam
public String getDisplayName()
{
if (_displayName == null)
return _name;
return _displayName;
}

View File

@ -0,0 +1,285 @@
package nautilus.game.arcade.game.games.bouncyballs;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.recharge.Recharge;
import org.bukkit.Color;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.util.Vector;
public class Ball
{
private BouncyBalls _host;
private Location _ballSpawn;
private Slime _ball;
private Vector _ballVel;
//Particle
protected Location _lastParticle = null;
//Ball Rebound
protected boolean _ignoreReboundForTick = false;
protected Location _lastLoc = null;
protected int _reboundX = 0;
protected int _reboundY = 0;
protected int _reboundZ = 0;
public Ball(BouncyBalls monsterLeague, Location ballSpawn)
{
_host = monsterLeague;
_ballSpawn = ballSpawn;
}
private void changeBallVelocity(Vector vel, boolean canGoNegativeY)
{
_ballVel = vel;
if (!canGoNegativeY && UtilEnt.isGrounded(_ball) && _ballVel.getY() <= 0)
_ballVel.setY(0);
_ballVel.setY(Math.min(_ballVel.getY(), 1));
//Rebound Data
_lastLoc = _ball.getLocation();
}
public void update()
{
//Spawn Ball
spawnBallUpdate();
if (_ball == null)
return;
//Particles
displayParticles();
//Kick
hitPlayerUpdate();
//Movement/Rebounds/etc
ballPhysics();
if (_ballVel.length() < 0.2)
changeBallVelocity(new Vector(
(Math.random() - 0.5) * 2,
(Math.random() - 0.5) * 2,
(Math.random() - 0.5) * 2), true);
}
private void displayParticles()
{
while (UtilMath.offset(_ball.getLocation().add(0, 0.5, 0), _lastParticle) > 0.15)
{
_lastParticle.add(UtilAlg.getTrajectory(_lastParticle, _ball.getLocation().add(0,0.5,0)).multiply(0.15));
// UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, _lastParticle, -1, 1, 1, 1, 0,
// ViewDist.MAX, UtilServer.getPlayers());
}
}
private void spawnBallUpdate()
{
if (_ball == null || !_ball.isValid())
{
if (_ball != null)
_ball.remove();
//Spawn
_host.CreatureAllowOverride = true;
_ball = _ballSpawn.getWorld().spawn(_ballSpawn, Slime.class);
_ball.setSize(2);
UtilEnt.Vegetate(_ball);
UtilEnt.ghost(_ball, false, false);
_host.CreatureAllowOverride = false;
_lastParticle = _ball.getLocation();
//Random Velocity Downwards
changeBallVelocity(new Vector(
(Math.random() - 0.5) * 2,
(Math.random() - 0.5) * 2,
(Math.random() - 0.5) * 2), true);
//Effect
UtilFirework.playFirework(_ballSpawn, Type.BALL, Color.WHITE, true, true);
}
}
private void hitPlayerUpdate()
{
for (Player player : _host.GetPlayers(true))
{
if (UtilMath.offset(player, _ball) < 1.5 ||
UtilMath.offset(player.getEyeLocation(), _ball.getLocation()) < 1.25)
{
if (Recharge.Instance.use(player, "Football Kick", 600, false, false))
{
//Damage
if (Recharge.Instance.use(player, "Hit by " + _ball.getEntityId(), 1000, false, false))
{
player.damage(5);
UtilAction.velocity(player, _ballVel, 1, true, 0.4, Math.max(0, _ballVel.getY()), 10, true);
}
else
{
continue;
}
//Set Ball Velocity
changeBallVelocity(_ballVel.multiply(-1), true);
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.SLIME,
_ball.getLocation(),
0, 0, 0, 0, 5, ViewDist.NORMAL, UtilServer.getPlayers());
//Flash Ball
_ball.playEffect(EntityEffect.HURT);
//Zero Player Vel
UtilAction.zeroVelocity(player);
//Ignore Rebound
_ignoreReboundForTick = true;
return;
}
}
}
}
private void ballPhysics()
{
//Wind Drag
// _ballVel = _ballVel.multiply(0.99);
//Ground Drag
// if (UtilEnt.isGrounded(_ball))
// _ballVel = _ballVel.multiply(0.97);
if (!_ignoreReboundForTick)
{
double lenience = 0.1;
//Rebound Y
if (_ballVel.getY() > 0.15 && _ball.getLocation().getY() <= _lastLoc.getY() ||
_ballVel.getY() < -lenience && _ball.getLocation().getY() >= _lastLoc.getY())
{
_reboundY++;
if (_reboundY > 1)
{
_ballVel.setY(_ballVel.getY() * -1);
// _ballVel = _ballVel.multiply(_ballVel.getY() > 0 ? 0.9 : 0.75); //Lose extra when bouncing on ground.
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
_reboundY = 0;
}
}
else
{
_reboundY = 0;
}
if (UtilEnt.isGrounded(_ball))
{
//lenience = 0.1;
}
//Rebound X
if (_ballVel.getX() > lenience && _ball.getLocation().getX() <= _lastLoc.getX() ||
_ballVel.getX() < -lenience && _ball.getLocation().getX() >= _lastLoc.getX())
{
_reboundX++;
if (_reboundX > 1)
{
_ballVel.setX(_ballVel.getX() * -1);
// _ballVel = _ballVel.multiply(0.9);
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
_reboundX = 0;
}
}
else
{
_reboundX = 0;
}
//Rebound Z
if (_ballVel.getZ() > lenience && _ball.getLocation().getZ() <= _lastLoc.getZ() ||
_ballVel.getZ() < -lenience && _ball.getLocation().getZ() >= _lastLoc.getZ())
{
_reboundZ++;
if (_reboundZ > 1)
{
_ballVel.setZ(_ballVel.getZ() * -1);
// _ballVel = _ballVel.multiply(0.9);
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
_reboundZ = 0;
}
}
else
{
_reboundZ = 0;
}
}
//Gravity
if (!UtilEnt.isGrounded(_ball))
_ballVel.setY(_ballVel.getY() - 0.04);
//Store Current Location
_lastLoc = _ball.getLocation();
_ignoreReboundForTick = false;
//Move Ball
_ball.setVelocity(_ballVel);
}
}

View File

@ -0,0 +1,67 @@
package nautilus.game.arcade.game.games.bouncyballs;
import java.util.ArrayList;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
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.game.SoloGame;
import nautilus.game.arcade.game.games.bouncyballs.kits.*;
import nautilus.game.arcade.game.games.bouncyballs.Ball;
import nautilus.game.arcade.kit.Kit;
public class BouncyBalls extends SoloGame
{
private ArrayList<Ball> _balls = new ArrayList<Ball>();
public BouncyBalls(ArcadeManager manager)
{
super(manager, GameType.BouncyBalls,
new Kit[]
{
new KitPlayer(manager),
},
new String[]
{
"BOUNCE"
});
this.HungerSet = 20;
}
@EventHandler
public void ballUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if(GetState() != GameState.Live)
return;
int ballCount = 10;
ballCount += (System.currentTimeMillis() - getGameLiveTime()) / 5000;
if (_balls.size() < ballCount)
_balls.add(new Ball(this, WorldData.GetDataLocs("BLUE").get(0)));
for (Ball ball : _balls)
ball.update();
}
@EventHandler
public void arrowDeflect(CustomDamageEvent event)
{
if (!(event.GetDamageeEntity() instanceof Slime))
return;
event.SetCancelled("NO DAMAGE");
}
}

View File

@ -0,0 +1,46 @@
package nautilus.game.arcade.game.games.bouncyballs.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkFletcher;
import nautilus.game.arcade.kit.perks.PerkRopedArrow;
public class KitPlayer extends Kit
{
public KitPlayer(ArcadeManager manager)
{
super(manager, "hello", KitAvailability.Gem,
new String[]
{
"hi"
},
new Perk[]
{
},
EntityType.PLAYER,
new ItemStack(Material.BOW));
}
@Override
public void GiveItems(Player player)
{
}
@Override
public void SpawnCustom(LivingEntity ent)
{
}
}

View File

@ -118,6 +118,7 @@ public class Build extends SoloGame
private int _countdownTimerState = 0;
private String[] _words;
private String[] _holidayWords;
private String _word = "?";
@ -140,20 +141,20 @@ public class Build extends SoloGame
private ChatColor _hintColor = ChatColor.YELLOW;
private ChatColor _firstHintColor = ChatColor.YELLOW;
public Build(ArcadeManager manager)
public Build(ArcadeManager manager)
{
super(manager, GameType.Build,
new Kit[]
{
new KitBuilder(manager),
new KitBuilder(manager),
},
new String[]
{
"Be creative and build something",
"based on the build theme!"
});
new String[]
{
"Be creative and build something",
"based on the build theme!"
});
this.StrictAntiHack = true;
this.Damage = false;
@ -161,7 +162,7 @@ public class Build extends SoloGame
this.HealthSet = 20;
this.BlockBreak = true;
this.BlockPlace = true;
this.BlockPlace = true;
this.ItemDrop = true;
this.ItemPickup = true;
@ -173,32 +174,42 @@ public class Build extends SoloGame
this.PrepareFreeze = false;
this.CreatureAllow = true;
this.WorldFireSpread = true;
this.WorldBoneMeal = true;
this.DontAllowOverfill = true;
UtilServer.getServer().spigot().getConfig().set("view-distance", 4);
_words = new String[]
{
"Rollercoaster", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House",
"Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Pot of Gold", "Shrek", "Fruit", "Breakfast",
"Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Spongebob", "Car", "Potted Plant", "Weapons",
"Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Helicopter", "Knight", "Rabbit",
"Sandwich", "Snowman", "Ice Cream", "Sea Shell", "Rainbow",
"Volcano", "Hot Tub", "Octopus", "Ghost", "Ant", "Cheese", "Kite Flying", "Reptile",
"Space Ship", "Pixel Art", "Chicken", "Shoe", "Owl", "Bear", "Flowers", "Lighthouse",
"Lion", "Television", "Batman", "Tiger", "Castle", "House",
"Bed", "Party", "Volleyball", "Toys", "Library", "Love", "Skull",
"Hat", "Snake", "Vacation", "Umbrella", "Magic", "Tornado", "Candy", "Dentist", "Pizza", "Bird",
"Superhero", "Turtle", "Chicken", "Build Anything!", "Food", "Picnic",
"Trophy", "Pool Party", "Hot Air Balloon", "Train", "Chocolate Bar",
"Clown", "Windmill", "Alligator",
"Police", "Igloo", "Gift", "Bumblebee", "Jellyfish", "Speedboat",
"Fall", "Summer", "Autumn", "Winter", "Disco", "Moose",
"Water Gun", "Astronaut", "Wither", "Meteor"
"Rollercoaster", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House",
"Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Pot of Gold", "Shrek", "Fruit", "Breakfast",
"Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Spongebob", "Car", "Potted Plant", "Weapons",
"Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Helicopter", "Knight", "Rabbit",
"Sandwich", "Snowman", "Ice Cream", "Sea Shell", "Rainbow",
"Volcano", "Hot Tub", "Octopus", "Ghost", "Ant", "Cheese", "Kite Flying", "Reptile",
"Space Ship", "Pixel Art", "Chicken", "Shoe", "Owl", "Bear", "Flowers", "Lighthouse",
"Lion", "Television", "Batman", "Tiger", "Castle", "House",
"Bed", "Party", "Volleyball", "Toys", "Library", "Love", "Skull",
"Hat", "Snake", "Vacation", "Umbrella", "Magic", "Tornado", "Candy", "Dentist", "Pizza", "Bird",
"Superhero", "Turtle", "Chicken", "Build Anything!", "Food", "Picnic",
"Trophy", "Pool Party", "Hot Air Balloon", "Train", "Chocolate Bar",
"Clown", "Windmill", "Alligator",
"Police", "Igloo", "Gift", "Bumblebee", "Jellyfish", "Speedboat",
"Fall", "Summer", "Autumn", "Winter", "Disco", "Moose",
"Water Gun", "Astronaut", "Wither", "Meteor"
};
_holidayWords = new String[]
{
"Santa", "Reindeer", "Ornament", "Elf", "North Pole", "Candy Cane", "Xmas Lights", "Christmas Tree",
"Fireplace", "Hot Chocolate", "Snowflake", "Snowman", "Sleigh", "Toys", "Milk", "Eggnog", "Coal",
"Cookies", "Mistletoe", "Icicle", "Gingerbread", "Stocking", "Jingle Bells", "Family", "Mittens",
"Snowball Fight", "Decorations", "Snow Fort", "Chimney", "Scrooge", "Sweater", "Ice Skating",
"Pinecone", "Cabin", "Bells", "Cold", "Nutcracker", "Sled", "Mrs. Claus", "Grinch", "Igloo",
"Boots", "Gingerbread Man", "Glacier", "Ice Hockey", "Scarf", "Snowboard"
};
_mobShop = new MobShop(getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation());
@ -238,7 +249,10 @@ public class Build extends SoloGame
player.setFlySpeed(0.1f);
}
_word = _words[UtilMath.r(_words.length)];
if (Math.random() >= 0.5)
_word = _words[UtilMath.r(_words.length)];
else
_word = _holidayWords[UtilMath.r(_holidayWords.length)];
UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + _word, 0, 80, 5);

View File

@ -83,6 +83,7 @@ public class Draw extends SoloGame
private HashSet<Tool> _tools;
private String[] _words;
private String[] _holidayWords;
private HashSet<String> _usedWords = new HashSet<String>();
public Draw(ArcadeManager manager)
@ -113,6 +114,16 @@ public class Draw extends SoloGame
"Bird", "Volcano", "Sloth", "Love", "Dance", "Hair", "Glasses", "Domino", "Dice", "Computer", "Top Hat", "Beard", "Wind", "Rain", "Minecraft", "Push", "Fighting", "Juggle", "Clown", "Miner", "Creeper", "Ghast", "Spider", "Punch", "Roll", "River", "Desert", "Cold", "Pregnant", "Photo", "Quick", "Mario", "Luigi", "Bridge", "Turtle", "Door Knob", "Mineplex", "Binoculars", "Telescope", "Planet", "Mountain Bike", "Moon", "Comet", "Flower", "Squirrel", "Horse Riding", "Chef", "Elephant", "Yoshi", "Shotgun", "Pistol", "James Bond", "Money", "Salt and Pepper", "Truck", "Helicopter", "Hot Air Balloon", "Sprout", "Yelling", "Muscles", "Skinny", "Zombie", "Lava", "Snake", "Motorbike", "Whale", "Boat", "Letterbox", "Window", "Lollipop", "Handcuffs", "Police", "Uppercut", "Windmill", "Eyepatch", "Campfire", "Rainbow", "Storm", "Pikachu", "Charmander", "Tornado", "Crying", "King", "Hobo", "Worm", "Snail", "XBox", "Playstation", "Nintendo", "Duck", "Pull", "Dinosaur", "Alligator", "Ankle", "Angel", "Acorn", "Bread", "Booty", "Bacon", "Crown", "Donut", "Drill", "Leash", "Magic", "Wizard", "Igloo", "Plant", "Screw", "Rifle", "Puppy", "Stool", "Stamp", "Letter", "Witch", "Zebra", "Wagon", "Compass", "Watch", "Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish", "Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl", "Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti", "Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel", "Cheese", "Beans", "Water", "Chicken", "Cannibal", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster", "Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone", "Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate", "Lightning", "Stomach", "Belly Button", "Fishing Rod", "Iron Ore", "Diamonds", "Emeralds", "Nether Portal", "Ender Dragon", "Rabbit", "Harry Potter", "Torch", "Light", "Battery", "Zombie Pigman", "Telephone", "Tent", "Hand", "Traffic Lights", "Anvil", "Tail", "Umbrella", "Piston", "Skeleton", "Spikes", "Bridge", "Bomb", "Spoon", "Rainbow", "Staircase", "Poop", "Dragon", "Fire", "Apple", "Shoe", "Squid", "Cookie", "Tooth", "Camera", "Sock", "Monkey", "Unicorn", "Smile", "Pool", "Rabbit", "Cupcake", "Pancake", "Princess", "Castle", "Flag", "Planet", "Stars", "Camp Fire", "Rose", "Spray", "Pencil", "Ice Cream", "Toilet", "Moose", "Bear", "Beer", "Batman", "Eggs", "Teapot", "Golf Club", "Tennis Racket", "Shield", "Crab", "Pot of Gold", "Cactus", "Television", "Pumpkin Pie", "Chimney", "Stable", "Nether", "Wither", "Beach", "Stop Sign", "Chestplate", "Pokeball", "Christmas Tree", "Present", "Snowflake", "Laptop", "Superman", "Football", "Basketball", "Creeper", "Tetris", "Jump", "Ninja", "Baby", "Troll Face", "Grim Reaper", "Temple", "Explosion", "Vomit", "Ants", "Barn", "Burn", "Baggage", "Frisbee", "Iceberg", "Sleeping", "Dream", "Snorlax", "Balloons", "Elevator", "Alligator", "Bikini", "Butterfly", "Bumblebee", "Pizza", "Jellyfish", "Sideburns", "Speedboat", "Treehouse", "Water Gun", "Drink", "Hook", "Dance", "Fall", "Summer", "Autumn", "Spring", "Winter", "Night Time", "Galaxy", "Sunrise", "Sunset", "Picnic", "Snowflake", "Holding Hands", "America", "Laptop", "Anvil", "Bagel", "Bench", "Cigar", "Darts", "Muffin", "Queen", "Wheat", "Dolphin", "Scarf", "Swing", "Thumb", "Tomato", "Alcohol", "Armor", "Alien", "Beans", "Cheek", "Phone", "Keyboard", "Orange", "Calculator", "Paper", "Desk", "Disco", "Elbow", "Drool", "Giant", "Golem", "Grave", "Llama", "Moose", "Party", "Panda", "Plumber", "Salsa", "Salad", "Skunk", "Skull", "Stump", "Sugar", "Ruler", "Bookcase", "Hamster", "Soup", "Teapot", "Towel", "Waist", "Archer", "Anchor", "Bamboo", "Branch", "Booger", "Carrot", "Cereal", "Coffee", "Wolf", "Crayon", "Finger", "Forest", "Hotdog", "Burger", "Obsidian", "Pillow", "Swing", "YouTube", "Farm", "Rain", "Cloud", "Frozen", "Garbage", "Music", "Twitter", "Facebook", "Santa Hat", "Rope", "Neck", "Sponge", "Sushi", "Noodles", "Soup", "Tower", "Berry", "Capture", "Prison", "Robot", "Trash", "School", "Skype", "Snowman", "Crowd", "Bank", "Mudkip", "Joker", "Lizard", "Tiger", "Royal", "Erupt", "Wizard", "Stain", "Cinema", "Notebook", "Blanket", "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Kirby" , "Brush" , "Violin", "Car", "Sun", "Eye", "Bow", "Axe", "Face", "Mushroom", "Guitar", "Book",
};
_holidayWords = new String[]
{
"Santa", "Reindeer", "Ornament", "Elf", "North Pole", "Candy Cane", "Christmas Tree",
"Fireplace", "Hot Chocolate", "Snowflake", "Snowman", "Sleigh", "Toys", "Milk", "Eggnog", "Coal",
"Cookies", "Mistletoe", "Icicle", "Gingerbread", "Stocking", "Jingle Bells", "Family", "Mittens",
"Snowball Fight", "Decorations", "Snow Fort", "Chimney", "Scrooge", "Sweater", "Ice Skating",
"Pinecone", "Cabin", "Bells", "Cold", "Nutcracker", "Sled", "Grinch", "Igloo",
"Boots", "Gingerbread Man", "Glacier", "Ice Hockey", "Scarf", "Snowboard"
};
_tools = new HashSet<Tool>();
_tools.add(new ToolLine(this));
_tools.add(new ToolSquare(this));
@ -282,12 +293,22 @@ public class Draw extends SoloGame
public String GetWord()
{
//Get Word
String word = _words[UtilMath.r(_words.length)];
String word = getRandomWord();
while (!_usedWords.add(word))
word = _words[UtilMath.r(_words.length)];
word = getRandomWord();
return word;
}
private String getRandomWord()
{
if (Math.random() >= 0.30)
{
return _words[UtilMath.r(_words.length)];
}
return _holidayWords[UtilMath.r(_holidayWords.length)];
}
@EventHandler(priority = EventPriority.LOWEST)
public void Guess(AsyncPlayerChatEvent event)

View File

@ -77,8 +77,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.sun.xml.internal.ws.resources.UtilMessages;
public class EventGame extends Game
{
private GameHostManager _mps;

View File

@ -0,0 +1,416 @@
package nautilus.game.arcade.game.games.monsterleague;
import java.util.ArrayList;
import java.util.HashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.monsterleague.kits.LeagueKit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Slime;
import org.bukkit.util.Vector;
public class Ball
{
private MonsterLeague _host;
private Location _ballSpawn;
private Slime _ball;
private Vector _ballVel;
private boolean _firstSpawn = true;
private long _ballDeadTime = -1;
private GameTeam _lastKickTeam = null;
private ArrayList<KickLog> _kickHistory = new ArrayList<KickLog>();
//Kick
protected int _kickTickDelay = 0;
//Particle
protected Location _lastParticle = null;
//Ball Rebound
protected boolean _ignoreReboundForTick = false;
protected Location _lastLoc = null;
protected int _reboundX = 0;
protected int _reboundY = 0;
protected int _reboundZ = 0;
public Ball(MonsterLeague monsterLeague, Location ballSpawn)
{
_host = monsterLeague;
_ballSpawn = ballSpawn;
}
private void changeBallVelocity(Vector vel, boolean canGoNegativeY)
{
_ballVel = vel;
if (!canGoNegativeY && UtilEnt.isGrounded(_ball) && _ballVel.getY() <= 0)
_ballVel.setY(0);
_ballVel.setY(Math.min(_ballVel.getY(), 1));
//Rebound Data
_lastLoc = _ball.getLocation();
}
public void update()
{
//New Ball Needed
checkNewBallNeeded();
//Spawn Ball
spawnBallUpdate();
if (_ball == null)
return;
//Particles
displayParticles();
//Kick
kickBallUpdate();
//Movement/Rebounds/etc
ballPhysics();
//Goal
scoreGoalUpdate();
}
private void checkNewBallNeeded()
{
if (_ballDeadTime == -1 && (_ball == null || !_ball.isValid()))
{
if (_ball != null)
_ball.remove();
_ballDeadTime = System.currentTimeMillis();
}
}
private void displayParticles()
{
if (_lastKickTeam == null)
{
_lastParticle = _ball.getLocation();
return;
}
while (UtilMath.offset(_ball.getLocation().add(0, 0.5, 0), _lastParticle) > 0.15)
{
_lastParticle.add(UtilAlg.getTrajectory(_lastParticle, _ball.getLocation().add(0,0.5,0)).multiply(0.15));
if (_lastKickTeam.GetColor() == ChatColor.AQUA)
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, _lastParticle, -1, 1, 1, 1, 0,
ViewDist.MAX, UtilServer.getPlayers());
}
else if (_lastKickTeam.GetColor() == ChatColor.RED)
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, _lastParticle, 0, 0, 0, 0, 1,
ViewDist.MAX, UtilServer.getPlayers());
}
else if (_lastKickTeam.GetColor() == ChatColor.GREEN)
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, _lastParticle, 0, 1, 0, 0, 1,
ViewDist.MAX, UtilServer.getPlayers());
}
else if (_lastKickTeam.GetColor() == ChatColor.YELLOW)
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, _lastParticle, -1, 1, -1, 0, 1,
ViewDist.MAX, UtilServer.getPlayers());
}
}
}
private void spawnBallUpdate()
{
if (_ballDeadTime > 0 && (_firstSpawn || UtilTime.elapsed(_ballDeadTime, 6000)))
{
//Spawn
_host.CreatureAllowOverride = true;
_ball = _ballSpawn.getWorld().spawn(_ballSpawn, Slime.class);
_ball.setSize(2);
UtilEnt.Vegetate(_ball);
UtilEnt.ghost(_ball, false, false);
_host.CreatureAllowOverride = false;
_lastParticle = _ball.getLocation();
//Set Ball to Alive
_ballDeadTime = -1;
//Velocity Downwards
changeBallVelocity(new Vector(0,-0.1,0), true);
//Effect
UtilFirework.playFirework(_ballSpawn, Type.BALL, Color.WHITE, true, true);
_firstSpawn = false;
}
}
private void kickBallUpdate()
{
if (_kickTickDelay > 0)
{
_kickTickDelay--;
return;
}
for (Player player : _host.GetPlayers(true))
{
if (UtilMath.offset(player, _ball) < 1.5 ||
UtilMath.offset(player.getEyeLocation(), _ball.getLocation()) < 1.25)
{
if (Recharge.Instance.use(player, "Football Kick", 600, false, false))
{
//Kick Power
LeagueKit kit = (LeagueKit)_host.GetKit(player);
//Set Ball Velocity
changeBallVelocity(player.getLocation().getDirection().multiply(kit.getKickPower()).add(new Vector(0, 0.4, 0)), false);
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.SLIME,
_ball.getLocation(),
0, 0, 0, 0, 5, ViewDist.NORMAL, UtilServer.getPlayers());
//Flash Ball
_ball.playEffect(EntityEffect.HURT);
//Zero Player Vel
UtilAction.zeroVelocity(player);
//Record
_lastKickTeam = _host.GetTeam(player);
_kickHistory.add(0, new KickLog(player, _lastKickTeam));
//Ignore Rebound
_ignoreReboundForTick = true;
//This creates a small delay that no one else can kick it.
_kickTickDelay = 2;
return;
}
}
}
}
private void ballPhysics()
{
//Wind Drag
_ballVel = _ballVel.multiply(0.99);
//Ground Drag
if (UtilEnt.isGrounded(_ball))
_ballVel = _ballVel.multiply(0.97);
if (!_ignoreReboundForTick)
{
double lenience = 0.1;
//Rebound Y
if (_ballVel.getY() > 0.15 && _ball.getLocation().getY() <= _lastLoc.getY() ||
_ballVel.getY() < -lenience && _ball.getLocation().getY() >= _lastLoc.getY())
{
_reboundY++;
if (_reboundY > 1)
{
_ballVel.setY(_ballVel.getY() * -1);
_ballVel = _ballVel.multiply(_ballVel.getY() > 0 ? 0.9 : 0.75); //Lose extra when bouncing on ground.
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
_reboundY = 0;
}
}
else
{
_reboundY = 0;
}
if (UtilEnt.isGrounded(_ball))
{
//lenience = 0.1;
}
//Rebound X
if (_ballVel.getX() > lenience && _ball.getLocation().getX() <= _lastLoc.getX() ||
_ballVel.getX() < -lenience && _ball.getLocation().getX() >= _lastLoc.getX())
{
_reboundX++;
if (_reboundX > 1)
{
_ballVel.setX(_ballVel.getX() * -1);
_ballVel = _ballVel.multiply(0.9);
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
_reboundX = 0;
}
}
else
{
_reboundX = 0;
}
//Rebound Z
if (_ballVel.getZ() > lenience && _ball.getLocation().getZ() <= _lastLoc.getZ() ||
_ballVel.getZ() < -lenience && _ball.getLocation().getZ() >= _lastLoc.getZ())
{
_reboundZ++;
if (_reboundZ > 1)
{
_ballVel.setZ(_ballVel.getZ() * -1);
_ballVel = _ballVel.multiply(0.9);
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
_reboundZ = 0;
}
}
else
{
_reboundZ = 0;
}
}
//Gravity
if (!UtilEnt.isGrounded(_ball))
_ballVel.setY(_ballVel.getY() - 0.04);
//Store Current Location
_lastLoc = _ball.getLocation();
_ignoreReboundForTick = false;
//Move Ball
_ball.setVelocity(_ballVel);
}
private boolean scoreGoalUpdate()
{
for (GameTeam team : _host.GetTeamList())
{
if (!_host.getGoalRegions().containsKey(team))
continue;
if (_host.getGoalRegions().get(team).contains(_ball.getLocation().getBlock()))
{
//Score
if (!_host.scoreGoal(team, this))
return false;
//Effect
UtilFirework.playFirework(_ball.getLocation(), Type.BALL, team.GetColorBase(), true, true);
//Clean
_ball.remove();
_ball = null;
_lastLoc = null;
_lastKickTeam = null;
_kickHistory.clear();
return true;
}
}
return false;
}
public Player getLastKickerNotOnTeam(GameTeam goalTeam)
{
for (KickLog log : _kickHistory)
{
if (log.Team.equals(goalTeam))
continue;
return log.Player;
}
return _kickHistory.get(0).Player;
}
public void arrowHit(LivingEntity ent, Projectile proj)
{
if (_ball != null && _ball.equals(ent))
{
Player player = (Player)proj.getShooter();
changeBallVelocity(proj.getVelocity().multiply(0.6), true);
//Sound
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);
//Effect
UtilParticle.PlayParticle(ParticleType.SLIME,
_ball.getLocation(),
0, 0, 0, 0, 5, ViewDist.NORMAL, UtilServer.getPlayers());
//Flash Ball
_ball.playEffect(EntityEffect.HURT);
//Zero Player Vel
UtilAction.zeroVelocity(player);
//Record
_lastKickTeam = _host.GetTeam(player);
_kickHistory.add(0, new KickLog(player, _lastKickTeam));
//Ignore Rebound
_ignoreReboundForTick = true;
}
}
}

View File

@ -0,0 +1,18 @@
package nautilus.game.arcade.game.games.monsterleague;
import nautilus.game.arcade.game.GameTeam;
import org.bukkit.entity.Player;
public class KickLog
{
Player Player;
GameTeam Team;
long Time;
public KickLog(Player player, GameTeam team)
{
Player = player;
Team = team;
Time = System.currentTimeMillis();
}
}

View File

@ -0,0 +1,248 @@
package nautilus.game.arcade.game.games.monsterleague;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ProjectileHitEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
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.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.monsterleague.kits.*;
import nautilus.game.arcade.kit.Kit;
public class MonsterLeague extends TeamGame
{
private HashMap<GameTeam, ArrayList<Block>> _teamGoalRegions = new HashMap<GameTeam, ArrayList<Block>>();
private HashMap<GameTeam, Integer> _teamScores = new HashMap<GameTeam, Integer>();
private ArrayList<Ball> _balls = new ArrayList<Ball>();
private int _scoreToWin = 5;
public MonsterLeague(ArcadeManager manager)
{
super(manager, GameType.MonsterLeague,
new Kit[]
{
new KitSkeleton(manager),
new KitGolem(manager),
new KitEnderman(manager),
},
new String[]
{
"CHEESE IZ DELISH"
});
this.PrepareFreeze = false;
this.DamagePvP = false;
this.HungerSet = 20;
this.HealthSet = 20;
this.DeathOut = false;
this.TeamArmor = true;
this.TeamArmorHotbar = true;
}
//Supports anywhere from 2-4 teams on a map
@Override
public void ParseData()
{
//parse200 56 73 14 129
//Scores
for (GameTeam team : GetTeamList())
{
_teamScores.put(team, 0);
}
//Red
if (GetTeam(ChatColor.RED) != null)
{
ArrayList<Block> goalBlocks = new ArrayList<Block>();
for (Location loc : WorldData.GetCustomLocs("" + Material.REDSTONE_ORE.getId()))
{
goalBlocks.add(loc.getBlock());
loc.getBlock().setType(Material.AIR);
}
_teamGoalRegions.put(GetTeam(ChatColor.RED), goalBlocks);
}
//Blue
if (GetTeam(ChatColor.AQUA) != null)
{
ArrayList<Block> goalBlocks = new ArrayList<Block>();
for (Location loc : WorldData.GetCustomLocs("" + Material.DIAMOND_ORE.getId()))
{
goalBlocks.add(loc.getBlock());
loc.getBlock().setType(Material.AIR);
}
_teamGoalRegions.put(GetTeam(ChatColor.AQUA), goalBlocks);
}
//Yellow
if (GetTeam(ChatColor.YELLOW) != null)
{
ArrayList<Block> goalBlocks = new ArrayList<Block>();
for (Location loc : WorldData.GetCustomLocs("" + Material.GOLD_ORE.getId()))
{
goalBlocks.add(loc.getBlock());
loc.getBlock().setType(Material.AIR);
}
_teamGoalRegions.put(GetTeam(ChatColor.YELLOW), goalBlocks);
}
//Green
if (GetTeam(ChatColor.GREEN) != null)
{
ArrayList<Block> goalBlocks = new ArrayList<Block>();
for (Location loc : WorldData.GetCustomLocs("" + Material.EMERALD_ORE.getId()))
{
goalBlocks.add(loc.getBlock());
loc.getBlock().setType(Material.AIR);
}
_teamGoalRegions.put(GetTeam(ChatColor.GREEN), goalBlocks);
}
//Support for multiple balls
_balls.add(new Ball(this, WorldData.GetDataLocs("GREEN").get(0)));
}
@EventHandler
public void ballUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if(GetState() != GameState.Live)
return;
for (Ball ball : _balls)
ball.update();
}
public boolean scoreGoal(final GameTeam goalOwnerTeam, final Ball ball)
{
Player lastKicker = ball.getLastKickerNotOnTeam(goalOwnerTeam);
GameTeam kickerTeam = GetTeam(lastKicker);
//Dont allow self score (will only happen if NO ONE else kicked it)
if (kickerTeam.equals(goalOwnerTeam))
return false;
//Add Score
_teamScores.put(kickerTeam, 1 + _teamScores.get(kickerTeam));
//Against for 3+ teams
String against = "";
if (GetTeamList().size() >= 3)
{
against = "against " + goalOwnerTeam.GetColor() + goalOwnerTeam.GetName() + ChatColor.RESET + " ";
}
//Check Win
if (_teamScores.get(kickerTeam) > _scoreToWin)
{
SetCustomWinLine(kickerTeam.GetColor() + lastKicker.getName() + ChatColor.RESET + " scored the final goal " + against + "for " + kickerTeam.GetColor() + kickerTeam.GetName());
//Announce
AnnounceEnd(kickerTeam);
for (GameTeam curTeam : GetTeamList())
{
if (WinnerTeam != null && curTeam.equals(WinnerTeam))
{
for (Player player : curTeam.GetPlayers(false))
AddGems(player, 10, "Winning Team", false, false);
}
for (Player player : curTeam.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false, false);
}
//End
SetState(GameState.End);
return true;
}
UtilTextMiddle.display("GOAL",
kickerTeam.GetColor() + lastKicker.getName() + C.cWhite + " scored " + against + "for " + kickerTeam.GetColor() + kickerTeam.GetName(),
0, 80, 20, UtilServer.getPlayers());
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
String scores = "";
for (GameTeam team : GetTeamList())
{
scores += "" + team.GetColor() + _teamScores.get(team) + ChatColor.RESET + " : ";
}
if (scores.length() > 0)
scores = scores.substring(0, scores.length()-3);
UtilTextMiddle.display("SCORES",
scores,
0, 40, 20, UtilServer.getPlayers());
}
}, 80);
return true;
}
public HashMap<GameTeam, ArrayList<Block>> getGoalRegions()
{
return _teamGoalRegions;
}
@EventHandler
public void arrowDeflect(CustomDamageEvent event)
{
event.SetCancelled("NO DAMAGE");
if (!(event.GetDamageeEntity() instanceof Slime))
return;
if (event.GetProjectile() == null || !(event.GetProjectile() instanceof Arrow) || event.GetProjectile().getShooter() == null)
return;
for (Ball ball : _balls)
{
ball.arrowHit(event.GetDamageeEntity(), event.GetProjectile());
}
}
}

View File

@ -0,0 +1,54 @@
package nautilus.game.arcade.game.games.monsterleague.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.monsterleague.perks.PerkBlinkMonsterLeague;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
public class KitEnderman extends LeagueKit
{
public KitEnderman(ArcadeManager manager)
{
super(manager, "Enderman", KitAvailability.Free, 5000,
new String[]
{
"Kick Power: 1.4",
},
new Perk[]
{
new PerkDoubleJump("Double Jump", 1, 1, true),
new PerkBlinkMonsterLeague("Blink", 32, 16000),
},
EntityType.ENDERMAN,
new ItemStack(Material.AIR), 1.4);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.EYE_OF_ENDER, (byte)0, 1,
C.cYellow + C.Bold + "Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Blink"));
//
// //Disguise
// DisguiseEnderman disguise = new DisguiseEnderman(player);
//
// if (Manager.GetGame().GetTeam(player) != null)
// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
// else
// disguise.setName(player.getName());
//
// disguise.setCustomNameVisible(true);
// Manager.GetDisguise().disguise(disguise);
}
}

View File

@ -0,0 +1,57 @@
package nautilus.game.arcade.game.games.monsterleague.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseIronGolem;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.monsterleague.perks.PerkStoneWall;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkSlow;
public class KitGolem extends LeagueKit
{
public KitGolem(ArcadeManager manager)
{
super(manager, "Golem", KitAvailability.Free, 5000,
new String[]
{
"Kick Power: 1.8",
},
new Perk[]
{
new PerkDoubleJump("Double Jump", 0.8, 0.8, true),
new PerkStoneWall("Iron Wall", Material.IRON_BLOCK, Material.IRON_INGOT),
new PerkSlow(0)
},
EntityType.IRON_GOLEM,
new ItemStack(Material.AIR), 1.8);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_INGOT, (byte)0, 1,
C.cYellow + C.Bold + "Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Iron Wall"));
//
// //Disguise
// DisguiseIronGolem disguise = new DisguiseIronGolem(player);
//
// if (Manager.GetGame().GetTeam(player) != null)
// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
// else
// disguise.setName(player.getName());
//
// disguise.setCustomNameVisible(true);
// Manager.GetDisguise().disguise(disguise);
}
}

Some files were not shown because too many files have changed in this diff Show More