use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class RegionEvents method blockBreak.
@EventHandler(ignoreCancelled = true)
private void blockBreak(BlockBreakEvent event) {
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
final Location loc2 = event.getBlock().getLocation();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (!ply.isInMinigame()) {
return;
}
for (Node node : RegionModule.getMinigameModule(ply.getMinigame()).getNodes()) {
if (node.getLocation().getWorld() == loc2.getWorld()) {
Location loc1 = node.getLocation();
if (loc1.getBlockX() == loc2.getBlockX() && loc1.getBlockY() == loc2.getBlockY() && loc1.getBlockZ() == loc2.getBlockZ()) {
node.execute(Triggers.getTrigger("BLOCK_BREAK"), ply);
}
}
}
for (Region region : RegionModule.getMinigameModule(ply.getMinigame()).getRegions()) {
if (region.locationInRegion(loc2)) {
region.execute(Triggers.getTrigger("BLOCK_BREAK"), ply);
}
}
});
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class BasicRecorder method blockPlace.
@EventHandler(priority = EventPriority.HIGH)
private void blockPlace(BlockPlaceEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame() && !event.isCancelled()) {
if (!ply.getMinigame().hasStarted() || ply.isLatejoining()) {
event.setCancelled(true);
return;
}
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlock().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlock().getType()))) && mgm.canBlockPlace()) {
d.addBlock(event.getBlockReplacedState(), ply);
} else {
event.setCancelled(true);
}
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class BasicRecorder method paintingPlace.
@EventHandler(ignoreCancelled = true)
private void paintingPlace(HangingPlaceEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply.isInMinigame()) {
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(Material.PAINTING)) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(Material.PAINTING))) || ((d.getWhitelistMode() && d.getWBBlocks().contains(Material.ITEM_FRAME)) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(Material.ITEM_FRAME)))) {
d.addEntity(event.getEntity(), ply, true);
} else {
event.setCancelled(true);
}
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class EditCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
if (args != null) {
if (plugin.getMinigameManager().hasMinigame(args[0])) {
Minigame mgm = plugin.getMinigameManager().getMinigame(args[0]);
if (mgm == null) {
plugin.getLogger().warning("The Minigame requested has a configuration" + " problem and is returning nulls");
return false;
}
MinigamePlayer player = plugin.getPlayerManager().getMinigamePlayer((Player) sender);
// noinspection ConstantConditions sanity check
if (player == null) {
plugin.getLogger().warning("Player is null");
Thread.dumpStack();
return false;
}
mgm.displayMenu(player);
} else {
sender.sendMessage(ChatColor.RED + "There is no Minigame by the name " + args[0]);
}
return true;
}
return false;
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class EndCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
if (args == null && sender instanceof Player) {
MinigamePlayer ply = plugin.getPlayerManager().getMinigamePlayer((Player) sender);
if (ply.isInMinigame()) {
forceEnd(sender, ply);
} else {
sender.sendMessage(ChatColor.RED + "Error: You are not in a minigame!");
}
return true;
} else if (args != null) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (player == null || player.hasPermission("minigame.end.other")) {
Player playertoEnd = Bukkit.getPlayerExact(args[0]);
MinigamePlayer ply = null;
Team team = null;
Minigame mgm = null;
if (args.length == 2 && plugin.getMinigameManager().hasMinigame(args[1])) {
TeamColor color = TeamColor.matchColor(args[0]);
mgm = plugin.getMinigameManager().getMinigame(args[1]);
if (mgm == null) {
sender.sendMessage(ChatColor.RED + "No minigme found by the name " + args[1]);
return true;
}
if (TeamsModule.getMinigameModule(mgm).hasTeam(color)) {
team = TeamsModule.getMinigameModule(mgm).getTeam(color);
} else {
sender.sendMessage(ChatColor.RED + "No team found by the name " + args[0] + " in " + mgm.getName(false));
return true;
}
} else if (args.length == 2 && !plugin.getMinigameManager().hasMinigame(args[1])) {
sender.sendMessage(ChatColor.RED + "No Minigame found by the name " + args[1]);
return true;
} else if (playertoEnd != null) {
ply = plugin.getPlayerManager().getMinigamePlayer(playertoEnd);
} else {
sender.sendMessage(ChatColor.RED + "No player found by the name " + args[0]);
return true;
}
if (ply != null && ply.isInMinigame()) {
forceEnd(sender, ply);
} else if (args.length >= 2 && team != null && mgm != null) {
if (mgm.hasPlayers()) {
List<MinigamePlayer> w = new ArrayList<>(team.getPlayers());
int lcount = 0;
for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
if (t != team) {
lcount += t.getPlayers().size();
}
}
List<MinigamePlayer> l = new ArrayList<>(lcount);
for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
if (t != team) {
l.addAll(t.getPlayers());
}
}
plugin.getPlayerManager().endMinigame(mgm, w, l);
sender.sendMessage(ChatColor.GRAY + "You forced " + team.getChatColor() + team.getDisplayName() + ChatColor.GRAY + " to win the Minigame.");
} else {
sender.sendMessage(ChatColor.RED + "This Minigame has no players!");
}
} else {
sender.sendMessage(ChatColor.RED + "This player is not playing a Minigame.");
}
} else if (player != null) {
sender.sendMessage(ChatColor.RED + "Error: You don't have permission to force end another players Minigame!");
sender.sendMessage(ChatColor.RED + "minigame.end.other");
}
return true;
}
return false;
}
Aggregations