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

This commit is contained in:
Jonathan Williams 2014-09-24 01:32:03 -07:00
commit a54a2aadc0
11 changed files with 450 additions and 101 deletions

View File

@ -56,6 +56,7 @@ public class MusicGadget extends Gadget
return;
}
//Near Portal
for (Block block : UtilBlock.getInRadius(player.getLocation(), 3).keySet())
{
if (block.getType() == Material.PORTAL)
@ -65,6 +66,28 @@ public class MusicGadget extends Gadget
}
}
//Invalid Location
Block block = player.getLocation().getBlock();
for (int x=-1 ; x<=1 ; x++)
for (int z=-1 ; z<=1 ; z++)
if (!UtilBlock.airFoliage(block.getRelative(x, 0, z)))
{
UtilPlayer.message(player, F.main("Music", "You cannot place a Jukebox here."));
return;
}
//Near Parkour
ArrayList<Block> blocks = new ArrayList<Block>();
blocks.add(block);
GadgetBlockEvent gadgetBlockEvent = new GadgetBlockEvent(this, blocks);
Bukkit.getServer().getPluginManager().callEvent(gadgetBlockEvent);
if (gadgetEvent.isCancelled())
{
UtilPlayer.message(player, F.main("Music", "You cannot place a Jukebox here."));
return;
}
player.getWorld().playEffect(player.getLocation(), Effect.RECORD_PLAY, _id);
_songs.add(new SongData(player.getLocation().getBlock(), _duration));

View File

@ -1,11 +1,6 @@
package mineplex.core.mount.types;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
@ -13,7 +8,6 @@ import org.bukkit.entity.Horse.Variant;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.mount.HorseMount;
@ -46,39 +40,39 @@ public class MountFrost extends HorseMount
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0.1f, 4);
}
@EventHandler
public void SnowAura(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Horse horse : GetActive().values())
{
//Blocks
double duration = 2000;
HashMap<Block, Double> blocks = UtilBlock.getInRadius(horse.getLocation(), 2.5d);
for (Iterator<Entry<Block, Double>> blockIterator = blocks.entrySet().iterator(); blockIterator.hasNext();)
{
Block block = blockIterator.next().getKey();
HashMap<Block, Double> snowBlocks = UtilBlock.getInRadius(block.getLocation(), 2d);
boolean addSnow = true;
for (Block surroundingBlock : snowBlocks.keySet())
{
if (surroundingBlock.getType() == Material.PORTAL || surroundingBlock.getType() == Material.CACTUS)
{
blockIterator.remove();
addSnow = false;
break;
}
}
if (addSnow)
Manager.getBlockRestore().Snow(block, (byte)1, (byte)1, (long)(duration * (1 + blocks.get(block))), 250, 0);
}
}
}
// @EventHandler
// public void SnowAura(UpdateEvent event)
// {
// if (event.getType() != UpdateType.TICK)
// return;
//
// for (Horse horse : GetActive().values())
// {
// //Blocks
// double duration = 2000;
// HashMap<Block, Double> blocks = UtilBlock.getInRadius(horse.getLocation(), 2.5d);
//
// for (Iterator<Entry<Block, Double>> blockIterator = blocks.entrySet().iterator(); blockIterator.hasNext();)
// {
// Block block = blockIterator.next().getKey();
// HashMap<Block, Double> snowBlocks = UtilBlock.getInRadius(block.getLocation(), 2d);
//
// boolean addSnow = true;
//
// for (Block surroundingBlock : snowBlocks.keySet())
// {
// if (surroundingBlock.getType() == Material.PORTAL || surroundingBlock.getType() == Material.CACTUS)
// {
// blockIterator.remove();
// addSnow = false;
// break;
// }
// }
//
//
// if (addSnow)
// Manager.getBlockRestore().Snow(block, (byte)1, (byte)1, (long)(duration * (1 + blocks.get(block))), 250, 0);
// }
// }
// }
}

View File

@ -82,6 +82,7 @@ import mineplex.hub.modules.MapManager;
import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.TextManager;
import mineplex.hub.modules.TournamentInviter;
import mineplex.hub.modules.VisibilityManager;
import mineplex.hub.modules.WorldManager;
import mineplex.hub.party.Party;
@ -154,8 +155,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
new MapManager(this);
new WorldManager(this);
new JumpManager(this);
//new UHCManager(this);
//new UHCManager(this);
new TournamentInviter(this);
_news = new NewsManager(this);
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);

View File

@ -0,0 +1,135 @@
package mineplex.hub.modules;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.HubManager;
public class TournamentInviter extends MiniPlugin
{
private String[] invitees = new String[]
{
"Bluestone_FTW",
"adrien5d",
"zed0155",
"SubSonicDPS",
"charger134",
"rensy69",
"ghikft",
"ParaJon",
"Mmmmhbeans",
"Zilcor",
"kwcd",
"orangeguyy",
"kingcamas",
"TheHyperAsian",
"BossesCraftCake",
"Shadowsnippp3r",
"MySquishyTurtle",
"pyrodamage",
"Blazespot1",
"WiiTarted",
"Ghostgunner97",
"bbran21",
"StudlyWafflez",
"FrozenAodC",
"PikaBoyCraft",
"NoNowGetOut",
"CandleBlob",
"sad6boy",
"RacgiMan",
"stafford9",
"Wincraft12",
"13en2000",
};
private String[] backups = new String[]
{
"DeCouto_05",
"krusher430",
"duble11",
"IcyCaress",
"HeroG_ruha",
"TheCherry_Guy",
"Infernova86",
"epicswords02",
"lion2x",
"Brandon_Nish",
"LTplaysminecraft",
"BootFruit",
"Markus4445",
"jamescrafts8",
"iamlinked",
"axle1313",
"KainFTW",
"CreeperRain",
"thomasjinksybean",
"GamerFletch",
"Thepiggyassassin",
"Patu2010",
"Flying_pigglet",
"PowerMovingBacca",
"arduent",
"Aubble",
"MattaTackk22",
"boomdigity102",
"Creeper2341455",
"Amazing105",
};
public TournamentInviter(HubManager manager)
{
super("Map Manager", manager.GetPlugin());
}
@EventHandler
public void PlayerJoin(PlayerJoinEvent event)
{
for (String name : invitees)
{
if (!name.equalsIgnoreCase(event.getPlayer().getName()))
continue;
inviteMessage(event.getPlayer());
}
for (String name : backups)
{
if (!name.equalsIgnoreCase(event.getPlayer().getName()))
continue;
backupMessage(event.getPlayer());
}
}
private void inviteMessage(Player player)
{
UtilPlayer.message(player, C.cBlue + C.Strike + "----------------------------------------------------");
UtilPlayer.message(player, C.cAqua + C.Bold + " Fall Invitational");
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cWhite + "Congratulations! You have earned an invite to the final event");
UtilPlayer.message(player, C.cWhite + "for the 2014 Fall Invitational on September 27 at 3pm EST!");
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cWhite + "Please confirm that you can attend at this link;");
UtilPlayer.message(player, C.cGreen + C.Line + "www.tinyurl.com/fallinvitational");
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cBlue + C.Strike + "----------------------------------------------------");
}
private void backupMessage(Player player)
{
UtilPlayer.message(player, C.cBlue + C.Strike + "----------------------------------------------------");
UtilPlayer.message(player, C.cAqua + C.Bold + " Fall Invitational");
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cWhite + "You have earned a backup invite to the final event for the");
UtilPlayer.message(player, C.cWhite + "2014 Fall Invitational on September 27 at 3pm EST!");
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cWhite + "Please confirm that you can attend at this link;");
UtilPlayer.message(player, C.cGreen + C.Line + "www.tinyurl.com/fallinvitational");
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cBlue + C.Strike + "----------------------------------------------------");
}
}

View File

@ -183,6 +183,10 @@ public class Arcade extends JavaPlugin
{
config.Tournament = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TOURNAMENT_POINTS"))
{
config.TournamentPoints = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TEAM_REJOIN"))
{
config.TeamRejoin = Boolean.parseBoolean(tokens[1]);
@ -289,6 +293,8 @@ public class Arcade extends JavaPlugin
out.write("\nTOURNAMENT=" + config.Tournament + "\n");
out.write("\nTOURNAMENT_POINTS=" + config.TournamentPoints + "\n");
out.write("\nTEAM_REJOIN=" + config.TeamRejoin + "\n");
out.write("TEAM_AUTO_JOIN=" + config.TeamAutoJoin + "\n");
out.write("TEAM_FORCE_BALANCE=" + config.TeamForceBalance + "\n");

View File

@ -96,6 +96,7 @@ import nautilus.game.arcade.managers.GameLootManager;
import nautilus.game.arcade.managers.GameManager;
import nautilus.game.arcade.managers.GamePlayerManager;
import nautilus.game.arcade.managers.GameStatManager;
import nautilus.game.arcade.managers.GameTournamentManager;
import nautilus.game.arcade.managers.GameWorldManager;
import nautilus.game.arcade.managers.IdleManager;
import nautilus.game.arcade.managers.MiscManager;
@ -130,6 +131,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private GameManager _gameManager;
private GameLobbyManager _gameLobbyManager;
private GamePlayerManager _gamePlayerManager;
private GameTournamentManager _gameTournamentManager;
private GameWorldManager _gameWorldManager;
private ServerStatusManager _serverStatusManager;
private InventoryManager _inventoryManager;
@ -155,8 +157,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Games
private Game _game;
private HashMap<String, String> _tournamentTeam = new HashMap<String, String>();
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack,
@ -247,6 +247,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new GameFlagManager(this);
_gamePlayerManager = new GamePlayerManager(this);
new GameAchievementManager(this);
_gameTournamentManager = new GameTournamentManager(this);
new GameStatManager(this);
new GameLootManager(this, petManager);
_gameWorldManager = new GameWorldManager(this);
@ -401,6 +402,16 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _gameGemManager;
}
public GamePlayerManager GetGamePlayerManager()
{
return _gamePlayerManager;
}
public GameTournamentManager GetGameTournamentManager()
{
return _gameTournamentManager;
}
public GameWorldManager GetGameWorldManager()
{
@ -486,7 +497,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
+ "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
//Always Joinable
if (_game.JoinInProgress)
if (_game != null && _game.JoinInProgress)
{
event.setMotd(ChatColor.GREEN + "Recruiting" + extrainformation);
}
@ -530,8 +541,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + event.getPlayer().getName()));
else
event.setQuitMessage(null);
_tournamentTeam.remove(event.getPlayer().getName());
}
public Game GetGame()
@ -861,6 +870,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _serverConfig.Tournament;
}
public boolean IsTournamentPoints()
{
return _serverConfig.TournamentPoints;
}
public boolean IsTeamRejoin()
{
@ -958,43 +972,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
}
}
public void setTournamentTeam(Player player, GameTeam team)
{
if (!IsTeamRejoin())
return;
_tournamentTeam.put(player.getName(), team.GetName());
}
public void rejoinTournamentTeam(Player player)
{
if (_game == null)
return;
if (!_tournamentTeam.containsKey(player.getName()))
return;
GameTeam curPref = _game.GetTeamPreference(player);
if (curPref != null)
return;
GameTeam curTeam = _game.GetTeam(player);
if (curTeam != null)
return;
String teamName = _tournamentTeam.get(player.getName());
for (GameTeam team : _game.GetTeamList())
{
if (team.GetName().equalsIgnoreCase(teamName))
{
_gamePlayerManager.AddTeamPreference(_game, player, team);
break;
}
}
}
public ArcadeRepository getArcadeRepository()
{
return _arcadeRepository;

View File

@ -501,7 +501,7 @@ public abstract class Game implements Listener
Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase());
//Save Tournament Team
Manager.setTournamentTeam(player, team);
Manager.GetGameTournamentManager().setTournamentTeam(player, team);
}
public GameTeam ChooseTeam(Player player)

View File

@ -14,6 +14,8 @@ public class GameServerConfig
//Flags
public boolean Tournament = false;
public boolean TournamentPoints = false;
public boolean TeamRejoin = false;
public boolean TeamAutoJoin = true;
public boolean TeamForceBalance = true;

View File

@ -16,6 +16,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
@ -113,6 +114,18 @@ public class GameLootManager implements Listener
{
double chance = Math.min(0.5, 0.12 + (System.currentTimeMillis() - _startTime)/3600000d);
if (Manager.GetClients().Get(player).GetRank().Has(Rank.ULTRA))
{
if (Manager.GetClients().Get(player).GetRank().Has(Rank.HERO))
{
chance *= 1.5;
}
else
{
chance *= 1.25;
}
}
if (Math.random() > chance)
return;

View File

@ -485,21 +485,7 @@ public class GameManager implements Listener
}
}
@EventHandler
public void TeamTournamentAutoJoin(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Game game = Manager.GetGame();
if (game == null) return;
if (game.GetState() != GameState.Recruit)
return;
for (Player player : UtilServer.getPlayers())
Manager.rejoinTournamentTeam(player);
}
public boolean PlayerAdd(Game game, Player player, GameTeam team)
{

View File

@ -0,0 +1,210 @@
package nautilus.game.arcade.managers;
import java.util.ArrayList;
import java.util.HashMap;
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.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
public class GameTournamentManager implements Listener
{
ArcadeManager Manager;
private HashMap<String, String> _tournamentTeam = new HashMap<String, String>();
private HashMap<String, Integer> _tournamentPoints = new HashMap<String, Integer>();
public GameTournamentManager(ArcadeManager manager)
{
Manager = manager;
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin());
}
@EventHandler
public void TeamTournamentAutoJoin(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Game game = Manager.GetGame();
if (game == null) return;
if (game.GetState() != GameState.Recruit)
return;
for (Player player : UtilServer.getPlayers())
rejoinTournamentTeam(player);
}
public void setTournamentTeam(Player player, GameTeam team)
{
if (!Manager.IsTeamRejoin())
return;
_tournamentTeam.put(player.getName(), team.GetName());
}
public void rejoinTournamentTeam(Player player)
{
if (Manager.GetGame() == null)
return;
if (!_tournamentTeam.containsKey(player.getName()))
return;
GameTeam curPref = Manager.GetGame().GetTeamPreference(player);
if (curPref != null)
return;
GameTeam curTeam = Manager.GetGame().GetTeam(player);
if (curTeam != null)
return;
String teamName = _tournamentTeam.get(player.getName());
for (GameTeam team : Manager.GetGame().GetTeamList())
{
if (team.GetName().equalsIgnoreCase(teamName))
{
Manager.GetGamePlayerManager().AddTeamPreference(Manager.GetGame(), player, team);
break;
}
}
}
@EventHandler
public void pointsReward(GameStateChangeEvent event)
{
if (!Manager.IsTournamentPoints())
return;
if (event.GetState() != GameState.End)
return;
ArrayList<Player> places = event.GetGame().GetTeamList().get(0).GetPlacements(true);
for (int i=0 ; i<places.size() ; i++)
{
Player player = places.get(i);
int points = places.size() - i;
addTournamentPoints(player, points);
UtilPlayer.message(player,
F.main("Tournament", "You received " + F.elem(points + " Points") + " for placing " + F.elem((i+1)+"/"+places.size()) + "."));
}
}
@EventHandler
public void pointsScoreboard(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!Manager.IsTournamentPoints())
return;
for (Scoreboard scoreboard : Manager.GetLobby().GetScoreboards())
{
Objective objective = scoreboard.getObjective(DisplaySlot.BELOW_NAME);
if (objective == null)
{
objective = scoreboard.registerNewObjective("Points", "dummy");
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
}
for (Player player : UtilServer.getPlayers())
objective.getScore(player.getName()).setScore(getTournamentPoints(player.getName()));
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void pointsDisplay(GameStateChangeEvent event)
{
if (!Manager.IsTournamentPoints())
return;
if (event.GetState() != GameState.Dead)
return;
ArrayList<String> ranks = new ArrayList<String>();
while (ranks.size() < _tournamentPoints.size())
{
int bestPoints = 0;
String bestPlayer = null;
for (String cur : _tournamentPoints.keySet())
{
if (ranks.contains(cur))
continue;
int points = _tournamentPoints.get(cur);
if (points == 0)
continue;
if (bestPlayer == null || points < bestPoints)
{
bestPlayer = cur;
bestPoints = points;
}
}
if (bestPlayer == null)
break;
ranks.add(bestPlayer);
}
Bukkit.broadcastMessage(C.cBlue + C.Strike + C.Bold + "--------------------------------------------");
for (int i=0 ; i<ranks.size() ; i++)
{
Bukkit.broadcastMessage(C.cGold + getTournamentPoints(ranks.get(i)) + " Points" + " " + C.cWhite + ranks.get(i));
}
Bukkit.broadcastMessage(C.cBlue + C.Strike + C.Bold + "--------------------------------------------");
}
public int getTournamentPoints(String player)
{
if (!_tournamentPoints.containsKey(player))
_tournamentPoints.put(player, 0);
return _tournamentPoints.get(player);
}
public void addTournamentPoints(Player player, int points)
{
_tournamentPoints.put(player.getName(), points + getTournamentPoints(player.getName()));
}
@EventHandler
public void clean(PlayerQuitEvent event)
{
_tournamentTeam.remove(event.getPlayer().getName());
}
}