Gem Hunters base

This commit is contained in:
Sam 2016-12-06 19:28:23 +00:00
parent ddab450c8e
commit 19a214b454
12 changed files with 703 additions and 0 deletions

View File

@ -0,0 +1,5 @@
name: Gem-Hunters
main: mineplex.gemhunters.GemHunters
version: 0.1
commands:
playwire:

View File

@ -0,0 +1,22 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-plugin</artifactId>
<version>dev-SNAPSHOT</version>
<relativePath>../plugin.xml</relativePath>
</parent>
<name>Gem-Hunters</name>
<artifactId>mineplex-game-gemhunters</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,216 @@
package mineplex.gemhunters;
import static mineplex.core.Managers.require;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.chatsnap.SnapshotManager;
import mineplex.core.chatsnap.SnapshotPlugin;
import mineplex.core.chatsnap.SnapshotRepository;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.creature.Creature;
import mineplex.core.delayedtask.DelayedTask;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.explosion.Explosion;
import mineplex.core.friend.FriendManager;
import mineplex.core.give.Give;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.memory.MemoryFix;
import mineplex.core.message.MessageManager;
import mineplex.core.monitor.LagMeter;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Punish;
import mineplex.core.recharge.Recharge;
import mineplex.core.report.ReportManager;
import mineplex.core.report.ReportPlugin;
import mineplex.core.serverConfig.ServerConfiguration;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.visibility.VisibilityManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
/**
* Gem Hunters main class <br>
*
* TODO make documentation and a nice header
*
* @author Sam
*/
public class GemHunters extends JavaPlugin
{
private static final String WEB_CONFIG = "webServer";
private CoreClientManager _clientManager;
private DonationManager _donationManager;
@Override
public void onEnable()
{
// Load configuration
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
saveConfig();
// Get the web server address
String webServerAddress = getConfig().getString(WEB_CONFIG);
// Load core modules
CommandCenter.Initialize(this);
// Client Manager
_clientManager = new CoreClientManager(this, webServerAddress);
// Donation Manager
_donationManager = new DonationManager(this, _clientManager, webServerAddress);
// Command Centre
CommandCenter.Instance.setClientManager(_clientManager);
// Timings
require(TimingsFix.class);
// ItemStacks
ItemStackFactory.Initialize(this, false);
// Delayed Tasks
DelayedTask.Initialize(this);
// Recharge
Recharge.Initialize(this);
// Visibility
VisibilityManager.Initialize(this);
// Give
Give.Initialize(this);
// Server config
new ServerConfiguration(this, _clientManager);
// Teleport
new Teleport(this, _clientManager);
// Packets
PacketHandler packetHandler = require(PacketHandler.class);
// Vanish
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
// Preferences
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager);
// Why do these depend on each other... :(
incognito.setPreferencesManager(preferenceManager);
// Server Status
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
// Portal
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
// File Updater
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
// Punish
Punish punish = new Punish(this, webServerAddress, _clientManager);
// Disguises
require(DisguiseManager.class);
// Creatures
new Creature(this);
// GWEN
AntiHack antiHack = require(AntiHack.class);
antiHack.setKick(false);
Bukkit.getScheduler().runTask(this, antiHack::enableNewAnticheat);
// Block Restore
BlockRestore blockRestore = new BlockRestore(this);
// Ignoring
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
// Statistics
StatsManager statsManager = new StatsManager(this, _clientManager);
// Elo
EloManager eloManager = new EloManager(this, _clientManager);
// Achievements
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager, incognito, eloManager);
// Chat/Messaging
Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
// Fixes
new MemoryFix(this);
new FoodDupeFix(this);
// Explosions
new Explosion(this, blockRestore);
// Inventories
new InventoryManager(this, _clientManager);
// Reports
SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger()));
new SnapshotPlugin(this, snapshotManager, _clientManager);
new ReportPlugin(this, new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 1));
// Tag fix
new CustomTagFix(this, packetHandler);
// Holograms
new HologramManager(this, packetHandler);
// Now we finally get to enable the Gem Hunters main module
new ModuleGemHunters(_clientManager);
//UpdateEvent!!!
new Updater(this);
// Disable spigot's item merging
for (World world : getServer().getWorlds())
{
((CraftWorld) world).getHandle().spigotConfig.itemMerge = 0;
}
// Turn off the server's debugging
MinecraftServer.getServer().getPropertyManager().setProperty("debug", false);
SpigotConfig.debug = false;
}
@Override
public void onDisable()
{
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
}
}

View File

@ -0,0 +1,21 @@
package mineplex.gemhunters;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.gemhunters.scoreboard.ModuleScoreboard;
import mineplex.gemhunters.supplydrop.ModuleSupplyDrop;
@ReflectivelyCreateMiniPlugin
public class ModuleGemHunters extends MiniPlugin
{
public ModuleGemHunters(CoreClientManager clientManager)
{
super("Gem Hunters");
require(ModuleSupplyDrop.class);
new ModuleScoreboard(clientManager);
}
}

View File

@ -0,0 +1,36 @@
package mineplex.gemhunters.bounties;
import java.util.UUID;
import org.bukkit.entity.Player;
public class Bounty
{
private UUID _target;
private UUID _setter;
private int _amount;
public Bounty(Player target, Player setter, int amount)
{
_target = target.getUniqueId();
_setter = setter.getUniqueId();
_amount = amount;
}
public UUID getTarget()
{
return _target;
}
public UUID getSetter()
{
return _setter;
}
public int getAmount()
{
return _amount;
}
}

View File

@ -0,0 +1,81 @@
package mineplex.gemhunters.scoreboard;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.scoreboard.WritableMineplexScoreboard;
public class GemHuntersScoreboard extends WritableMineplexScoreboard
{
private static final String PRIMARY_COLOUR = C.cGreenB;
private static final String SECONDARY_COLOUR = C.cWhiteB;
private static final String TRANSITION_COLOUR = C.cDGreenB;
private String _title;
private int _shineIndex;
private boolean _shineDirection = true;
public GemHuntersScoreboard(Player player)
{
super(player);
_title = " GEM HUNTERS ";
setSidebarName(PRIMARY_COLOUR + _title);
}
public void writeContent(Player player)
{
writeNewLine();
write(C.cGreen + "Testing for " + player.getName());
writeNewLine();
}
public String getSuffix(Player perspective, Player subject)
{
return C.cGray + " " + perspective.getName();
}
public void updateTitle()
{
String out = (_shineDirection ? PRIMARY_COLOUR : SECONDARY_COLOUR);
for (int i = 0; i < _title.length(); i++)
{
char c = _title.charAt(i);
if (_shineDirection)
{
if (i == _shineIndex)
out += TRANSITION_COLOUR;
if (i == _shineIndex + 1)
out += SECONDARY_COLOUR;
}
else
{
if (i == _shineIndex)
out += TRANSITION_COLOUR;
if (i == _shineIndex + 1)
out += PRIMARY_COLOUR;
}
out += c;
}
setSidebarName(out);
_shineIndex++;
if (_shineIndex == _title.length() * 2)
{
_shineIndex = 0;
_shineDirection = !_shineDirection;
}
}
}

View File

@ -0,0 +1,117 @@
package mineplex.gemhunters.scoreboard;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ReflectivelyCreateMiniPlugin
public class ModuleScoreboard extends MiniPlugin
{
private CoreClientManager _clientManager;
private Map<UUID, GemHuntersScoreboard> _scoreboards;
public ModuleScoreboard(CoreClientManager clientManager)
{
super("Scoreboard");
_clientManager = clientManager;
_scoreboards = new HashMap<>();
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() == UpdateType.FAST)
{
for (UUID key : _scoreboards.keySet())
{
GemHuntersScoreboard scoreboard = _scoreboards.get(key);
Player player = UtilPlayer.searchExact(key);
scoreboard.writeContent(player);
scoreboard.draw();
}
}
else if (event.getType() == UpdateType.FASTEST)
{
for (GemHuntersScoreboard scoreboard : _scoreboards.values())
{
scoreboard.updateTitle();
}
}
}
@EventHandler
public void playerJoin(PlayerJoinEvent event)
{
createPlayerScoreboard(event.getPlayer());
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
for (GemHuntersScoreboard scoreboard : _scoreboards.values())
{
scoreboard.getHandle().getTeam(player.getName()).unregister();
}
_scoreboards.remove(player.getUniqueId());
}
public void createPlayerScoreboard(Player player)
{
if (!_scoreboards.containsKey(player.getUniqueId()))
{
GemHuntersScoreboard scoreboard = new GemHuntersScoreboard(player);
Scoreboard handle = scoreboard.getHandle();
_scoreboards.put(player.getUniqueId(), scoreboard);
String tag = _clientManager.Get(player).GetRank().getTag(true, true);
for (GemHuntersScoreboard other : _scoreboards.values())
{
Player otherPlayer = other.getOwner();
Team team = handle.registerNewTeam(otherPlayer.getName());
team.setPrefix(_clientManager.Get(otherPlayer).GetRank().getTag(true, true) + C.Reset + " ");
team.setSuffix(scoreboard.getSuffix(player, otherPlayer));
team.addEntry(otherPlayer.getName());
if (player.equals(otherPlayer))
{
continue;
}
Scoreboard otherHandle = other.getHandle();
Team otherTeam = otherHandle.registerNewTeam(player.getName());
otherTeam.setPrefix(tag + C.Reset + " ");
otherTeam.setSuffix(other.getSuffix(other.getOwner(), player));
otherTeam.addEntry(player.getName());
}
player.setScoreboard(scoreboard.getHandle());
}
}
}

View File

@ -0,0 +1,44 @@
package mineplex.gemhunters.supplydrop;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.supplydrop.commands.CommandSupplyDropTest;
@ReflectivelyCreateMiniPlugin
public class ModuleSupplyDrop extends MiniPlugin
{
private SupplyDrop _current;
private ModuleSupplyDrop()
{
super("Supply Drop");
}
@Override
public void addCommands()
{
addCommand(new CommandSupplyDropTest(this));
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || _current == null)
{
return;
}
_current.advancePath();
}
public void startHelicopter(Player player)
{
_current = new SupplyDrop(player.getLocation(), player.getLocation(), player.getLocation());
}
}

View File

@ -0,0 +1,128 @@
package mineplex.gemhunters.supplydrop;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import mineplex.core.common.util.UtilShapes;
/**
* Represents an instance of a Supply Drop. <br>
* A supply drop consists of a helicopter flying through the map from a one
* location to another. Upon reaching it's destination it will drop a loot chest
* which players can then fight over. <br>
* The helicopter will then fly away towards a despawning location. <br>
* <br>
* The helicopter will be made up of a collection of blocks that are moved along
* a linear path. The look of this helicopter is saved in the map and is stored
* in internal memory on startup. <br>
* <br>
* The blades of the helicopter rotate, this is done within this class. <br>
* <br>
* {@link ModuleSupplyDrop} handles when and where these supply drops will
* spawn.
*
* @author Sam
*/
public class SupplyDrop
{
private static final int BLADE_LENGTH = 7;
private Location _spawn;
private Location _destination;
private Location _despawn;
private Location _current;
private SupplyDropState _state;
private Set<Block> _bladeBlocks;
private boolean _diagonal;
public SupplyDrop(Location spawn, Location destination, Location despawn)
{
_spawn = spawn;
_destination = destination;
_despawn = despawn;
_current = spawn;
_state = SupplyDropState.MOVING_TO_DESTINATION;
_bladeBlocks = new HashSet<>();
_diagonal = false;
}
public void advancePath()
{
if (!isStopped())
{
}
_current.add(1, 0, 0);
rotateBlades();
}
public void rotateBlades()
{
_diagonal = !_diagonal;
for (Block block : _bladeBlocks)
{
block.setType(Material.AIR);
}
_bladeBlocks.clear();
if (_diagonal)
{
for (int x = -1; x <= 1; x += 2)
{
for (int z = -1; z <= 1; z += 2)
{
for (Location location : UtilShapes.getLinesLimitedPoints(_current, _current.clone().add(x * BLADE_LENGTH, 0, z * BLADE_LENGTH), BLADE_LENGTH))
{
Block block = location.getBlock();
_bladeBlocks.add(block);
block.setType(Material.STEP);
}
}
}
}
else
{
for (int x = -1; x <= 1; x += 2)
{
for (Location location : UtilShapes.getLinesLimitedPoints(_current, _current.clone().add(x * BLADE_LENGTH, 0, 0), BLADE_LENGTH))
{
Block block = location.getBlock();
_bladeBlocks.add(block);
block.setType(Material.STEP);
}
}
for (int z = -1; z <= 1; z += 2)
{
for (Location location : UtilShapes.getLinesLimitedPoints(_current, _current.clone().add(0, 0, z * BLADE_LENGTH), BLADE_LENGTH))
{
Block block = location.getBlock();
_bladeBlocks.add(block);
block.setType(Material.STEP);
}
}
}
}
public boolean isStopped()
{
return _state == SupplyDropState.STOPPED;
}
}

View File

@ -0,0 +1,8 @@
package mineplex.gemhunters.supplydrop;
public enum SupplyDropState
{
MOVING_TO_DESTINATION, STOPPED, MOVING_TO_DESPAWN
}

View File

@ -0,0 +1,24 @@
package mineplex.gemhunters.supplydrop.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.gemhunters.supplydrop.ModuleSupplyDrop;
public class CommandSupplyDropTest extends CommandBase<ModuleSupplyDrop>
{
public CommandSupplyDropTest(ModuleSupplyDrop plugin)
{
super(plugin, Rank.ADMIN, "stest");
}
@Override
public void Execute(Player caller, String[] args)
{
caller.sendMessage("Running!");
Plugin.startHelicopter(caller);
}
}

View File

@ -39,6 +39,7 @@
<module>Nautilus.Game.Arcade.UHC.WorldGen</module>
<module>mavericks-review-hub</module>
<module>mineplex-game-gemhunters</module>
</modules>
<repositories>