Add main menu, update mvp, and minor projectile changes
This commit is contained in:
parent
eab711f7ef
commit
917f0ac795
|
@ -5,10 +5,12 @@ import javax.inject.Inject;
|
|||
import me.anxuiz.settings.Setting;
|
||||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.bukkit.broadcast.model.BroadcastPrefix;
|
||||
import tc.oc.commons.bukkit.settings.SettingManagerProvider;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class BroadcastSettings {
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import me.anxuiz.settings.Setting;
|
|||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -27,6 +28,7 @@ import org.bukkit.permissions.Permission;
|
|||
import org.bukkit.permissions.PermissionDefault;
|
||||
import tc.oc.api.bukkit.users.OnlinePlayers;
|
||||
import tc.oc.commons.bukkit.settings.SettingManagerProvider;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
import tc.oc.commons.core.commands.Commands;
|
||||
|
||||
@Singleton
|
||||
|
|
|
@ -4,6 +4,8 @@ import me.anxuiz.settings.Setting;
|
|||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.EnumType;
|
||||
import me.anxuiz.settings.types.Name;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class PunishmentMessageSetting {
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package tc.oc.commons.bukkit.settings;
|
|||
import me.anxuiz.settings.Setting;
|
||||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
/**
|
||||
* TODO: Not implemented yet
|
||||
|
@ -10,7 +12,7 @@ import me.anxuiz.settings.types.BooleanType;
|
|||
public class RemoteTeleport {
|
||||
private static final Setting inst = new SettingBuilder()
|
||||
.name("RemoteTeleport").alias("rtp")
|
||||
.summary("Allow /tp to teleport you across servers, just like /rtp")
|
||||
.summary("Allow /tp to move you across servers like /rtp")
|
||||
.type(new BooleanType())
|
||||
.defaultValue(true).get();
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@ import me.anxuiz.settings.Setting;
|
|||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.EnumType;
|
||||
import me.anxuiz.settings.types.Name;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.nick.Familiarity;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class JoinMessageSetting {
|
||||
private static final Setting inst = new SettingBuilder()
|
||||
|
|
|
@ -4,9 +4,11 @@ import me.anxuiz.settings.Setting;
|
|||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.EnumType;
|
||||
import me.anxuiz.settings.types.Name;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import tc.oc.commons.bukkit.nick.Familiarity;
|
||||
import tc.oc.commons.bukkit.nick.Identity;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class WhisperSettings {
|
||||
|
||||
|
@ -25,7 +27,8 @@ public class WhisperSettings {
|
|||
.name("PrivateMessages")
|
||||
.alias("msg").alias("message").alias("messages").alias("pm").alias("pmr")
|
||||
.description(description).type(enumType).defaultValue(defaultValue)
|
||||
.summary("Who can send you private messages").get();
|
||||
.summary("Who can send you private messages")
|
||||
.get();
|
||||
|
||||
public static Setting receive() {
|
||||
return recieve;
|
||||
|
@ -41,7 +44,7 @@ public class WhisperSettings {
|
|||
.name("PrivateMessageSounds")
|
||||
.alias("sounds").alias("pmsound").alias("pms")
|
||||
.description(description).type(enumType).defaultValue(defaultValue)
|
||||
.summary("Whether you hear a sound when you receive a private message").get();
|
||||
.summary("Hear a sound when you get a message").get();
|
||||
|
||||
public static Setting sound() {
|
||||
return sound;
|
||||
|
|
|
@ -4,9 +4,11 @@ import me.anxuiz.settings.*;
|
|||
import me.anxuiz.settings.bukkit.PlayerSettingCallback;
|
||||
import me.anxuiz.settings.bukkit.PlayerSettings;
|
||||
import me.anxuiz.settings.types.EnumType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.bukkit.hologram.Hologram;
|
||||
import tc.oc.commons.bukkit.hologram.content.HologramAnimation;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import tc.oc.pgm.kits.KitManifest;
|
|||
import tc.oc.pgm.lane.LaneManifest;
|
||||
import tc.oc.pgm.blitz.BlitzManifest;
|
||||
import tc.oc.pgm.loot.LootManifest;
|
||||
import tc.oc.pgm.menu.MenuManifest;
|
||||
import tc.oc.pgm.modes.ObjectiveModeManifest;
|
||||
import tc.oc.pgm.physics.PlayerPhysicsManifest;
|
||||
import tc.oc.pgm.picker.PickerManifest;
|
||||
|
@ -70,5 +71,6 @@ public class PGMModulesManifest extends HybridManifest {
|
|||
install(new ObjectiveModeManifest());
|
||||
install(new BlitzManifest());
|
||||
install(new HighlightManifest());
|
||||
install(new MenuManifest());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@ package tc.oc.pgm.damage;
|
|||
import me.anxuiz.settings.Setting;
|
||||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class DamageSettings {
|
||||
|
||||
|
@ -10,13 +13,15 @@ public class DamageSettings {
|
|||
.name("DamageNumbers").alias("damage")
|
||||
.summary("Show floating damage numbers")
|
||||
.type(new BooleanType())
|
||||
.defaultValue(true).get();
|
||||
.defaultValue(true)
|
||||
.get();
|
||||
|
||||
public static final Setting KNOCKBACK_PARTICLES = new SettingBuilder()
|
||||
.name("KnockbackParticles").alias("kbparticles")
|
||||
.summary("Show knockback particles")
|
||||
.type(new BooleanType())
|
||||
.defaultValue(true).get();
|
||||
.defaultValue(true)
|
||||
.get();
|
||||
|
||||
public static final Setting ATTACK_SPEEDOMETER = new SettingBuilder()
|
||||
.name("AttackSpeedometer").alias("cps")
|
||||
|
|
|
@ -4,7 +4,9 @@ import me.anxuiz.settings.Setting;
|
|||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.EnumType;
|
||||
import me.anxuiz.settings.types.Name;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.nick.Familiarity;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class DeathMessageSetting {
|
||||
private static final Setting inst = new SettingBuilder()
|
||||
|
|
|
@ -4,11 +4,13 @@ import me.anxuiz.settings.Setting;
|
|||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.TypeParseException;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class HighlightDeathMessageSetting {
|
||||
private static final Setting INSTANCE = new SettingBuilder()
|
||||
.name("HighlightDeathMessages").alias("hdms").alias("hdm")
|
||||
.summary("Highlight death messages that you are involved in")
|
||||
.summary("Highlight your death messages")
|
||||
.type(new BooleanType() {
|
||||
@Override
|
||||
public Object parse(String raw) throws TypeParseException {
|
||||
|
|
|
@ -41,17 +41,17 @@ public class HighlightListener implements Listener {
|
|||
points += facet.matchKills();
|
||||
points -= facet.deaths();
|
||||
for (long wool : facet.getWoolCaptureTimes()) {
|
||||
int woolPoints = (int)((wool * 2.5) - 2);
|
||||
int woolPoints = (int)((wool * 2.25) - 2);
|
||||
points += Math.min(Math.max(woolPoints, 0), 120);
|
||||
}
|
||||
|
||||
for (long core : facet.getCoreLeakTimes()) {
|
||||
int corePoints = (int)((core * 2.5) - 2);
|
||||
int corePoints = (int)((core * 2.25) - 2);
|
||||
points += Math.min(Math.max(corePoints, 0), 120);
|
||||
}
|
||||
|
||||
for (DestroyableContribution destroyable : facet.getDestroyableDestroyTimes().keySet()) {
|
||||
int destroyablePoints = (int)((facet.getDestroyableDestroyTimes().get(destroyable) * 2.5 * destroyable.getPercentage()) - 2);
|
||||
int destroyablePoints = (int)((facet.getDestroyableDestroyTimes().get(destroyable) * 2.25 * destroyable.getPercentage()) - 2);
|
||||
points += Math.min(Math.max(destroyablePoints, 0), 120);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package tc.oc.pgm.menu;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import tc.oc.commons.bukkit.event.ObserverKitApplyEvent;
|
||||
import tc.oc.commons.bukkit.raindrops.RaindropConstants;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.core.util.Comparables;
|
||||
import tc.oc.pgm.events.MatchEndEvent;
|
||||
import tc.oc.pgm.events.ObserverInteractEvent;
|
||||
import tc.oc.pgm.match.Match;
|
||||
import tc.oc.pgm.match.MatchPlayer;
|
||||
import tc.oc.pgm.menu.gui.MainMenuButton;
|
||||
import tc.oc.pgm.teams.Team;
|
||||
import tc.oc.pgm.tokens.gui.MainTokenButton;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class MenuListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onObserverInteract(ObserverInteractEvent event) {
|
||||
if (event.getClickType() == ClickType.RIGHT) {
|
||||
MainMenuButton button = new MainMenuButton(event.getPlayer().getBukkit());
|
||||
ItemStack main = button.getIcon().create();
|
||||
//isSimilar so that stacks of the item will still open the menu
|
||||
if (event.getPlayer().getBukkit().getItemInHand().isSimilar(main)) {
|
||||
button.function(event.getPlayer().getBukkit());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveKitToObservers(ObserverKitApplyEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ItemStack main = new MainMenuButton(player).getIcon().create();
|
||||
player.getInventory().setItem(5, main);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package tc.oc.pgm.menu;
|
||||
|
||||
import tc.oc.commons.core.inject.HybridManifest;
|
||||
import tc.oc.pgm.match.inject.MatchBinders;
|
||||
import tc.oc.pgm.match.inject.MatchScoped;
|
||||
import tc.oc.pgm.tokens.TokenListener;
|
||||
|
||||
public class MenuManifest extends HybridManifest implements MatchBinders {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(MenuListener.class).in(MatchScoped.class);
|
||||
matchListener(MenuListener.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package tc.oc.pgm.menu.gui;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.bukkit.gui.buttons.Button;
|
||||
import tc.oc.commons.bukkit.util.Constants;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
import tc.oc.pgm.tokens.gui.MainTokenMenu;
|
||||
|
||||
public class MainMenuButton extends Button {
|
||||
|
||||
public MainMenuButton(Player player) {
|
||||
super(new ItemCreator(Material.ENCHANTED_BOOK)
|
||||
.setName(Constants.PREFIX + "Main Menu")
|
||||
.addLore(Constants.SUBTEXT + "Open the Main Menu",
|
||||
Constants.CLICK + "Right Click"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
player.openInventory(new MainMenuInterface(player).getInventory());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package tc.oc.pgm.menu.gui;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.bukkit.gui.buttons.Button;
|
||||
import tc.oc.commons.bukkit.gui.interfaces.ChestInterface;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.bukkit.util.Constants;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
import tc.oc.pgm.tokens.gui.MainTokenButton;
|
||||
import tc.oc.pgm.tokens.gui.MutationTokenInterface;
|
||||
import tc.oc.pgm.tokens.gui.TokenPurchaseInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MainMenuInterface extends ChestInterface {
|
||||
private static MainMenuInterface instance;
|
||||
|
||||
public MainMenuInterface(Player player) {
|
||||
super(player, new ArrayList<>(), 27, "Main Menu", getInstance());
|
||||
updateButtons();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChestInterface getParent() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
public static MainMenuInterface getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateButtons() {
|
||||
List<Button> buttons = new ArrayList<>();
|
||||
|
||||
MainTokenButton.getInstance().setSlot(11);
|
||||
buttons.add(MainTokenButton.getInstance());
|
||||
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.SKULL_ITEM)
|
||||
.setName(Constants.PREFIX + "Stats")
|
||||
.setData(3)
|
||||
, 13)); //TODO -- show stats in lore
|
||||
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.BOOK_AND_QUILL)
|
||||
.setName(Constants.PREFIX + "Settings")
|
||||
, 15) {
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
player.openInventory(new SettingsInterface(player).getInventory());
|
||||
}
|
||||
});
|
||||
|
||||
setButtons(buttons);
|
||||
updateInventory();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package tc.oc.pgm.menu.gui;
|
||||
|
||||
import com.google.api.client.util.Lists;
|
||||
import me.anxuiz.settings.Setting;
|
||||
import me.anxuiz.settings.SettingManager;
|
||||
import me.anxuiz.settings.Toggleable;
|
||||
import me.anxuiz.settings.bukkit.PlayerSettings;
|
||||
import me.anxuiz.settings.bukkit.plugin.Permissions;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.bukkit.gui.buttons.Button;
|
||||
import tc.oc.commons.bukkit.gui.buttons.empty.EmptyButton;
|
||||
import tc.oc.commons.bukkit.gui.interfaces.SinglePageInterface;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.bukkit.util.Constants;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
import tc.oc.pgm.PGM;
|
||||
import tc.oc.pgm.PGMTranslations;
|
||||
import tc.oc.pgm.mutation.Mutation;
|
||||
import tc.oc.pgm.mutation.MutationMatchModule;
|
||||
import tc.oc.pgm.mutation.command.MutationCommands;
|
||||
import tc.oc.pgm.picker.PickerSettings;
|
||||
import tc.oc.pgm.tokens.gui.MainTokenMenu;
|
||||
import tc.oc.pgm.tokens.gui.MutationConfirmInterface;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SettingsInterface extends SinglePageInterface {
|
||||
|
||||
public SettingsInterface(Player player) {
|
||||
super(player, new ArrayList<>(), 54, "Settings", MainMenuInterface.getInstance());
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setButtons() {
|
||||
List<Button> buttons = new ArrayList<>();
|
||||
List<Setting> settings = Lists.newArrayList(PlayerSettings.getRegistry().getSettings());
|
||||
Collections.sort(settings, new Comparator<Setting>() {
|
||||
public int compare(Setting s1, Setting s2) {
|
||||
return s1.getName().compareTo(s2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
for(Iterator<Setting> it = settings.iterator(); it.hasNext(); ) {
|
||||
Setting setting = it.next();
|
||||
if(!(setting.getType() instanceof Toggleable) ||
|
||||
!getPlayer().hasPermission("setting." + setting.getName().toLowerCase() + ".view") ||
|
||||
!getPlayer().hasPermission("setting." + setting.getName().toLowerCase() + ".set")) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
settings.forEach(setting -> buttons.add(getSettingButton(setting)));
|
||||
|
||||
setButtons(buttons);
|
||||
}
|
||||
|
||||
private Button getSettingButton(Setting setting) {
|
||||
ItemCreator itemCreator = new ItemCreator(setting.getExtra() instanceof Material ? (Material) setting.getExtra() : Material.PAPER)
|
||||
.setName(Constants.PREFIX + setting.getName())
|
||||
.addLore(Constants.SUBTEXT + setting.getSummary(),
|
||||
setting.getType().print(PlayerSettings.getManager(getPlayer()).getValue(setting)))
|
||||
.setHideFlags(ItemCreator.HideFlag.ALL);
|
||||
return new Button(itemCreator) {
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
SettingManager manager = PlayerSettings.getManager(player);
|
||||
Object newValue = ((Toggleable) setting.getType()).getNextState(manager.getValue(setting));
|
||||
manager.setValue(setting, newValue);
|
||||
player.sendMessage(setting.getName() + " toggled to " + setting.getType().print(newValue));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultButtons() {
|
||||
defaultButtons.clear();
|
||||
defaultButtons.add(this.lastPageButton);
|
||||
this.lastPageButton.setSlot(49);
|
||||
this.lastPageButton.setIcon(new ItemCreator(Material.WOOL)
|
||||
.setData(14)
|
||||
.setName(ChatColor.GREEN + "Go Back"));
|
||||
for (Integer integer : new Integer[]{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 17,
|
||||
18, 26,
|
||||
27, 35,
|
||||
36, 44,
|
||||
45, 46, 47, 48, 50, 51, 52, 53}) {
|
||||
EmptyButton button = new EmptyButton(integer);
|
||||
defaultButtons.add(button);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -3,13 +3,15 @@ package tc.oc.pgm.picker;
|
|||
import me.anxuiz.settings.Setting;
|
||||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class PickerSettings {
|
||||
private PickerSettings() {}
|
||||
|
||||
public static final Setting PICKER = new SettingBuilder()
|
||||
.name("Picker").alias("pkr")
|
||||
.summary("Open a helpful GUI for picking classes and teams")
|
||||
.summary("Get a GUI for choosing teams")
|
||||
.type(new BooleanType())
|
||||
.defaultValue(true).get();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package tc.oc.pgm.playerstats;
|
|||
import me.anxuiz.settings.Setting;
|
||||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class StatSettings {
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package tc.oc.pgm.projectile;
|
|||
import java.util.logging.Level;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
|
@ -76,6 +78,10 @@ public class ProjectilePlayerFacet implements MatchPlayerFacet, Listener {
|
|||
projectile.setMetadata(Projectiles.METADATA_KEY, new FixedMetadataValue(PGM.get(), definition));
|
||||
}
|
||||
|
||||
if (projectile instanceof Arrow && item.getEnchantments().containsKey(Enchantment.ARROW_INFINITE)) {
|
||||
((Arrow) projectile).setPickupRule(Arrow.PickupRule.DISALLOWED);
|
||||
}
|
||||
|
||||
// If the entity implements Projectile, it will have already generated a ProjectileLaunchEvent.
|
||||
// Otherwise, we fire our custom event.
|
||||
if(!realProjectile) {
|
||||
|
|
|
@ -3,6 +3,8 @@ package tc.oc.pgm.scoreboard;
|
|||
import me.anxuiz.settings.Setting;
|
||||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class ScoreboardSettings {
|
||||
private ScoreboardSettings() {}
|
||||
|
|
|
@ -4,6 +4,8 @@ import me.anxuiz.settings.Setting;
|
|||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.EnumType;
|
||||
import me.anxuiz.settings.types.Name;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
public class ObserverSetting {
|
||||
private static final Setting inst = new SettingBuilder()
|
||||
|
|
|
@ -5,8 +5,10 @@ import javax.inject.Singleton;
|
|||
import me.anxuiz.settings.Setting;
|
||||
import me.anxuiz.settings.SettingBuilder;
|
||||
import me.anxuiz.settings.types.BooleanType;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.bukkit.settings.SettingBinder;
|
||||
import tc.oc.commons.bukkit.settings.SettingCallbackBinder;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
import tc.oc.commons.core.inject.HybridManifest;
|
||||
|
||||
/**
|
||||
|
@ -35,13 +37,13 @@ public class Settings extends HybridManifest {
|
|||
|
||||
public static final Setting RATINGS = new SettingBuilder()
|
||||
.name("Ratings").alias("rate")
|
||||
.summary("Automatically show the map rating dialog for maps you haven't rated yet")
|
||||
.summary("Show map rating dialog for unrated maps")
|
||||
.type(new BooleanType())
|
||||
.defaultValue(true).get();
|
||||
|
||||
public static final Setting SOUNDS = new SettingBuilder()
|
||||
.name("Sounds").alias("sound")
|
||||
.summary("Hear sounds to alert you of the last three seconds of a countdown")
|
||||
.summary("Hear sounds at the end of a countdown")
|
||||
.type(new BooleanType())
|
||||
.defaultValue(true).get();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package tc.oc.pgm.streamermod;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.core.chat.Component;
|
||||
import tc.oc.pgm.destroyable.DestroyableContribution;
|
||||
import tc.oc.pgm.events.MatchEndEvent;
|
||||
import tc.oc.pgm.match.MatchPlayer;
|
||||
import tc.oc.pgm.match.MatchScheduler;
|
||||
import tc.oc.pgm.playerstats.StatsUserFacet;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class StreamerModListener implements Listener {
|
||||
|
||||
private final MatchScheduler scheduler;
|
||||
|
||||
@Inject
|
||||
StreamerModListener(MatchScheduler scheduler) {
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void matchEnd(MatchEndEvent event) {
|
||||
StatsUserFacet bestPlayerStats = null;
|
||||
MatchPlayer bestPlayer = null;
|
||||
double bestPlayerPoints = 0;
|
||||
|
||||
if (event.getMatch().getParticipatingPlayers().size() < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MatchPlayer player : event.getMatch().getParticipatingPlayers()) {
|
||||
StatsUserFacet facet = player.getUserContext().facet(StatsUserFacet.class);
|
||||
|
||||
double points = 0;
|
||||
points += facet.matchKills();
|
||||
points -= facet.deaths();
|
||||
for (long wool : facet.getWoolCaptureTimes()) {
|
||||
int woolPoints = (int)((wool * 2.5) - 2);
|
||||
points += Math.min(Math.max(woolPoints, 0), 120);
|
||||
}
|
||||
|
||||
for (long core : facet.getCoreLeakTimes()) {
|
||||
int corePoints = (int)((core * 2.5) - 2);
|
||||
points += Math.min(Math.max(corePoints, 0), 120);
|
||||
}
|
||||
|
||||
for (DestroyableContribution destroyable : facet.getDestroyableDestroyTimes().keySet()) {
|
||||
int destroyablePoints = (int)((facet.getDestroyableDestroyTimes().get(destroyable) * 2.5 * destroyable.getPercentage()) - 2);
|
||||
points += Math.min(Math.max(destroyablePoints, 0), 120);
|
||||
}
|
||||
|
||||
for (long flag : facet.getFlagCaptureTimes()) {
|
||||
int flagPoints = (int)(flag / 1.75);
|
||||
points += Math.min(Math.max(flagPoints, 0), 120);
|
||||
}
|
||||
|
||||
points += (facet.getBlocksBroken() / 20);
|
||||
|
||||
if (bestPlayerStats == null || points > bestPlayerPoints) {
|
||||
bestPlayerStats = facet;
|
||||
bestPlayer = player;
|
||||
bestPlayerPoints = points;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestPlayer != null) {
|
||||
final BaseComponent title = new Component(new TranslatableComponent("broadcast.gameOver.mvp"), ChatColor.AQUA, ChatColor.BOLD);
|
||||
Component subtitle;
|
||||
if (Math.random() < 0.05) {
|
||||
String appendMe;
|
||||
if (Math.random() > 0.25) {
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||
appendMe = ChatColor.YELLOW + ": +1 Mutation Token!";
|
||||
} else {
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||
appendMe = ChatColor.YELLOW + ": +1 SetNext Token!";
|
||||
}
|
||||
subtitle = new Component(bestPlayer.getDisplayName() + appendMe);
|
||||
} else {
|
||||
subtitle = new Component(bestPlayer.getDisplayName());
|
||||
}
|
||||
|
||||
for(MatchPlayer viewer : event.getMatch().getPlayers()) {
|
||||
scheduler.createDelayedTask(100L, () -> {
|
||||
viewer.showTitle(title, subtitle, 0, 60, 60);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package tc.oc.pgm.streamermod;
|
||||
|
||||
import tc.oc.commons.core.inject.HybridManifest;
|
||||
import tc.oc.pgm.map.inject.MapBinders;
|
||||
import tc.oc.pgm.match.MatchScope;
|
||||
import tc.oc.pgm.match.inject.MatchBinders;
|
||||
import tc.oc.pgm.match.inject.MatchScoped;
|
||||
|
||||
public class StreamerModManifest extends HybridManifest implements MapBinders, MatchBinders {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(StreamerModListener.class).in(MatchScoped.class);
|
||||
matchListener(StreamerModListener.class, MatchScope.LOADED);
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ import tc.oc.pgm.events.ListenerScope;
|
|||
import tc.oc.pgm.match.Match;
|
||||
import tc.oc.pgm.match.MatchModule;
|
||||
import tc.oc.pgm.match.MatchScope;
|
||||
import tc.oc.pgm.projectile.EntityLaunchEvent;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
|
@ -104,6 +105,21 @@ public class TNTMatchModule extends MatchModule implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void handleInstantActivation(EntityLaunchEvent event) {
|
||||
if(event.getEntity() instanceof TNTPrimed) {
|
||||
TNTPrimed tnt = (TNTPrimed) event.getEntity();
|
||||
|
||||
if(this.properties.fuse != null) {
|
||||
tnt.setFuseTicks(this.getFuseTicks());
|
||||
}
|
||||
|
||||
if(this.properties.power != null) {
|
||||
tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void setCustomProperties(ExplosionPrimeEvent event) {
|
||||
if(event.getEntity() instanceof TNTPrimed) {
|
||||
|
|
|
@ -33,13 +33,6 @@ public class TokenListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveKitToObservers(ObserverKitApplyEvent event) {
|
||||
ItemStack main = MainTokenButton.getInstance().getIcon().create();
|
||||
Player player = event.getPlayer();
|
||||
player.getInventory().setItem(5, main);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void handleMatchEndEvent(final MatchEndEvent event) {
|
||||
Match match = event.getMatch();
|
||||
|
|
|
@ -10,7 +10,7 @@ public class MainTokenButton extends Button {
|
|||
private static MainTokenButton instance;
|
||||
|
||||
public MainTokenButton() {
|
||||
super(null);
|
||||
super(13);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue