Get the plugin to actually start

This commit is contained in:
Sam 2018-07-13 14:35:41 +01:00 committed by Alexander Meech
parent c52908ec48
commit 28e77f78a3
8 changed files with 88 additions and 14 deletions

View File

@ -10,7 +10,6 @@ import mineplex.core.titles.tracks.TrackTier;
public class PowerPlayTrack extends Track public class PowerPlayTrack extends Track
{ {
private final BonusManager _bonusManager = Managers.require(BonusManager.class);
public PowerPlayTrack() public PowerPlayTrack()
{ {
@ -19,7 +18,8 @@ public class PowerPlayTrack extends Track
.addTier(new TrackTier( .addTier(new TrackTier(
"Power Play Club", "Power Play Club",
null, null,
player -> _bonusManager.getPowerPlayClubRepository().getCachedData(player).isSubscribed() ? 1L : 0L, // We have to get BonusManager here to prevent a big problem. Replace with a global variable if it can be created reflectively.
player -> Managers.get(BonusManager.class).getPowerPlayClubRepository().getCachedData(player).isSubscribed() ? 1L : 0L,
1, 1,
new TrackFormat(ChatColor.AQUA, ChatColor.AQUA) new TrackFormat(ChatColor.AQUA, ChatColor.AQUA)
)); ));

View File

@ -107,6 +107,7 @@ import mineplex.hub.news.NewsManager;
import mineplex.hub.parkour.ParkourManager; import mineplex.hub.parkour.ParkourManager;
import mineplex.hub.player.CreativeManager; import mineplex.hub.player.CreativeManager;
import mineplex.hub.player.HubPlayerManager; import mineplex.hub.player.HubPlayerManager;
import mineplex.hub.plugin.AnniversaryHubPlugin;
import mineplex.hub.plugin.HubPlugin; import mineplex.hub.plugin.HubPlugin;
import mineplex.hub.scoreboard.HubScoreboard; import mineplex.hub.scoreboard.HubScoreboard;
import mineplex.hub.world.HubPortalManager; import mineplex.hub.world.HubPortalManager;
@ -250,7 +251,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
_parkourManager = require(ParkourManager.class); _parkourManager = require(ParkourManager.class);
_jumpManager = new JumpManager(this); _jumpManager = new JumpManager(this);
_hubPlugin = new HubPlugin(); _hubPlugin = new AnniversaryHubPlugin();
// Disable chunk generation // Disable chunk generation
nmsWorld.generator = new VoidGenerator(); nmsWorld.generator = new VoidGenerator();

View File

@ -0,0 +1,16 @@
package mineplex.hub.plugin;
public class AnniversaryHubPlugin extends HubPlugin
{
public AnniversaryHubPlugin()
{
super("Anniversary");
}
@Override
protected void setupWorld()
{
_manager.GetSpawn().getWorld().setTime(18000);
}
}

View File

@ -596,6 +596,11 @@ public abstract class Game extends ListenerComponent implements Lifetimed
return null; return null;
} }
public boolean isAllowingGameStats()
{
return true;
}
public GameType GetType() public GameType GetType()
{ {
return _gameType; return _gameType;
@ -1642,12 +1647,22 @@ public abstract class Game extends ListenerComponent implements Lifetimed
return; return;
if (!_stats.containsKey(player)) if (!_stats.containsKey(player))
_stats.put(player, new HashMap<String, Integer>()); _stats.put(player, new HashMap<>());
if (global) if (global)
{
stat = "Global." + stat; stat = "Global." + stat;
}
else else
{
// In certain game modes (for example OP Bridges) we don't want to award game stats but global ones like EXP are fine.
if (!isAllowingGameStats())
{
return;
}
stat = GetName() + "." + stat; stat = GetName() + "." + stat;
}
if (Manager.IsTournamentServer()) if (Manager.IsTournamentServer())
stat += ".Tournament"; stat += ".Tournament";

View File

@ -58,4 +58,9 @@ public class OverpoweredBridge extends Bridge
return "OP Bridges"; return "OP Bridges";
} }
@Override
public boolean isAllowingGameStats()
{
return false;
}
} }

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -53,24 +54,37 @@ public class KitRetroSquid extends Kit
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void playerInteractEntity(PlayerInteractEntityEvent event)
{
if (event.getRightClicked() instanceof Player)
{
attemptLaser(event.getPlayer(), null);
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void playerInteract(PlayerInteractEvent event) public void playerInteract(PlayerInteractEvent event)
{ {
if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R)) if (!UtilEvent.isAction(event, ActionType.R))
{ {
return; return;
} }
Player player = event.getPlayer(); if (attemptLaser(event.getPlayer(), event.getClickedBlock()))
{
event.setCancelled(true);
}
}
private boolean attemptLaser(Player player, Block block)
{
ItemStack itemStack = player.getItemInHand(); ItemStack itemStack = player.getItemInHand();
Block block = event.getClickedBlock();
if (!HasKit(player) || !UtilItem.isAxe(itemStack) || UtilBlock.usable(block) || !Recharge.Instance.use(player, NAME, 1200, false, true)) if (!HasKit(player) || !UtilItem.isAxe(itemStack) || UtilBlock.usable(block) || !Recharge.Instance.use(player, NAME, 1200, false, true))
{ {
return; return false;
} }
event.setCancelled(true);
Location location = player.getEyeLocation(); Location location = player.getEyeLocation();
location.add(location.getDirection()); location.add(location.getDirection());
location.getWorld().playSound(location, Sound.FIREWORK_LAUNCH, 1, 1); location.getWorld().playSound(location, Sound.FIREWORK_LAUNCH, 1, 1);
@ -103,5 +117,7 @@ public class KitRetroSquid extends Kit
break; break;
} }
return true;
} }
} }

View File

@ -69,6 +69,7 @@ public class TugOfWool extends TeamGame
{ {
"Your animals are " + C.cRed + "Hungry" + C.Reset + ".", "Your animals are " + C.cRed + "Hungry" + C.Reset + ".",
"Guide them to " + C.cYellow + "Enemy Crops" + C.Reset + ".", "Guide them to " + C.cYellow + "Enemy Crops" + C.Reset + ".",
"Kill animals and players to get " + C.cGold + "Gold" + C.Reset + ".",
"Eat " + C.cAqua + "All" + C.Reset + " enemy crops to win!" "Eat " + C.cAqua + "All" + C.Reset + " enemy crops to win!"
}; };
private static final int MAX_ANIMALS = 30; private static final int MAX_ANIMALS = 30;
@ -619,7 +620,11 @@ public class TugOfWool extends TeamGame
public void incrementGold(Player player, double amount) public void incrementGold(Player player, double amount)
{ {
setGold(player, _gold.getOrDefault(player, 0D) + amount); setGold(player, _gold.getOrDefault(player, 0D) + amount);
AddGems(player, amount / 100D, "Gold Collected", false, true);
if (amount > 0)
{
AddGems(player, amount / 10D, "Gold Collected", true, true);
}
} }
public void setGold(Player player, double amount) public void setGold(Player player, double amount)

View File

@ -437,9 +437,25 @@ public class GameCreationManager implements Listener
private GameMode randomGameMode(List<String> modes, GameType type) private GameMode randomGameMode(List<String> modes, GameType type)
{ {
return UtilAlg.Random(Arrays.stream(type.getGameModes()) List<GameMode> possible = new ArrayList<>(Arrays.asList(type.getGameModes()));
.filter(gameMode -> modes.contains(gameMode.getName()) && (_lastMode == null || _lastMode.equals(gameMode.getName()))) possible.removeIf(gameMode -> !modes.contains(gameMode.getName()));
.collect(Collectors.toList()));
// If there's none or one mode for this gametype just use that one.
if (possible.isEmpty())
{
return null;
}
else if (possible.size() == 1)
{
return possible.get(0);
}
if (_lastMode != null)
{
possible.removeIf(gameMode -> _lastMode.equals(gameMode.getName()));
}
return UtilAlg.Random(possible);
} }
private GameMode getModeByName(GameMode[] gameModes, String gameModeName) private GameMode getModeByName(GameMode[] gameModes, String gameModeName)