mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
Bossbar reactions and stacking potato
This commit is contained in:
parent
aac791d768
commit
19ed60d407
7
pom.xml
7
pom.xml
@ -217,13 +217,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.ConnorLinfoot</groupId>
|
|
||||||
<artifactId>ActionBarAPI</artifactId>
|
|
||||||
<version>5b2d642d3d</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.goldtreeservers</groupId>
|
<groupId>net.goldtreeservers</groupId>
|
||||||
<artifactId>worldguardextraflags</artifactId>
|
<artifactId>worldguardextraflags</artifactId>
|
||||||
|
@ -61,12 +61,7 @@ public class ChatManager extends FreedomService
|
|||||||
PlayerData data = plugin.pl.getData(player);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
plugin.sh.reactionString = "";
|
plugin.sh.endReaction(player.getName());
|
||||||
Date currentTime = new Date();
|
|
||||||
long seconds = (currentTime.getTime() - plugin.sh.reactionStartTime.getTime()) / 1000;
|
|
||||||
String reactionMessage = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] "
|
|
||||||
+ ChatColor.GREEN + player.getName() + ChatColor.AQUA + " won in " + seconds + " seconds!";
|
|
||||||
FUtil.bcastMsg(reactionMessage, false);
|
|
||||||
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
|||||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||||
import me.totalfreedom.totalfreedommod.fun.MP44;
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
||||||
import me.totalfreedom.totalfreedommod.fun.MobStacker;
|
|
||||||
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
@ -125,7 +124,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public CurseListener cul;
|
public CurseListener cul;
|
||||||
public ItemFun it;
|
public ItemFun it;
|
||||||
public Landminer lm;
|
public Landminer lm;
|
||||||
public MobStacker ms;
|
|
||||||
public MP44 mp;
|
public MP44 mp;
|
||||||
public Jumppads jp;
|
public Jumppads jp;
|
||||||
public Trailer tr;
|
public Trailer tr;
|
||||||
@ -259,7 +257,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
cul = new CurseListener();
|
cul = new CurseListener();
|
||||||
it = new ItemFun();
|
it = new ItemFun();
|
||||||
lm = new Landminer();
|
lm = new Landminer();
|
||||||
ms = new MobStacker();
|
|
||||||
mp = new MP44();
|
mp = new MP44();
|
||||||
jp = new Jumppads();
|
jp = new Jumppads();
|
||||||
tr = new Trailer();
|
tr = new Trailer();
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import com.connorlinfoot.actionbarapi.ActionBarAPI;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Brings the current reaction string up on your action bar", usage = "/<command>")
|
@CommandParameters(description = "Forcefully start a reaction", usage = "/<command>")
|
||||||
public class Command_reactionbar extends FreedomCommand
|
public class Command_reactionbar extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (!plugin.sh.reactionString.isEmpty())
|
if (!FUtil.isDeveloper(sender.getName()))
|
||||||
{
|
{
|
||||||
ActionBarAPI.sendActionBar(playerSender, ChatColor.BOLD + plugin.sh.reactionString, 15 * 20);
|
return noPerms();
|
||||||
}
|
}
|
||||||
|
plugin.sh.forceStartReaction();
|
||||||
|
msg("Started a reaction.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
||||||
|
public class Command_stackingpotato extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.STACKING_POTATO))
|
||||||
|
{
|
||||||
|
playerSender.getInventory().addItem(plugin.sh.getStackingPotato());
|
||||||
|
msg("You have been given a Stacking Potato", ChatColor.GREEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("You do not own the Stacking Potato! Purchase one from the shop.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -82,23 +82,20 @@ public enum ConfigEntry
|
|||||||
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
|
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
|
||||||
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
|
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
|
||||||
//
|
//
|
||||||
DONATION_PROBOARDS_URL(String.class, "donation.proboards_url"),
|
|
||||||
DONATION_GROUP_ID(String.class, "donation.donator_group_id"),
|
|
||||||
DONATION_SESSION_ID(String.class, "donation.session_id"),
|
|
||||||
DONATION_CSRF_TOKEN(String.class, "donation.csrf_token"),
|
|
||||||
//
|
|
||||||
SHOP_ENABLED(Boolean.class, "shop.enabled"),
|
SHOP_ENABLED(Boolean.class, "shop.enabled"),
|
||||||
SHOP_TITLE(String.class, "shop.title"),
|
SHOP_TITLE(String.class, "shop.title"),
|
||||||
SHOP_PREFIX(String.class, "shop.prefix"),
|
SHOP_PREFIX(String.class, "shop.prefix"),
|
||||||
SHOP_COINS_PER_VOTE(Integer.class, "shop.coins_per_vote"),
|
SHOP_COINS_PER_VOTE(Integer.class, "shop.coins_per_vote"),
|
||||||
SHOP_REACTIONS_ENABLED(Boolean.class, "shop.reactions.enabled"),
|
SHOP_REACTIONS_ENABLED(Boolean.class, "shop.reactions.enabled"),
|
||||||
SHOP_REACTIONS_INTERVAL(Integer.class, "shop.reactions.interval"),
|
SHOP_REACTIONS_INTERVAL(Integer.class, "shop.reactions.interval"),
|
||||||
|
SHOP_REACTIONS_TIME(Double.class, "shop.reactions.time"),
|
||||||
SHOP_REACTIONS_COINS_PER_WIN(Integer.class, "shop.reactions.coins_per_win"),
|
SHOP_REACTIONS_COINS_PER_WIN(Integer.class, "shop.reactions.coins_per_win"),
|
||||||
SHOP_REACTIONS_STRING_LENGTH(Integer.class, "shop.reactions.string_length"),
|
SHOP_REACTIONS_STRING_LENGTH(Integer.class, "shop.reactions.string_length"),
|
||||||
SHOP_PRICES_GRAPPLING_HOOK(Integer.class, "shop.prices.grappling_hook"),
|
SHOP_PRICES_GRAPPLING_HOOK(Integer.class, "shop.prices.grappling_hook"),
|
||||||
SHOP_PRICES_LIGHTNING_ROD(Integer.class, "shop.prices.lightning_rod"),
|
SHOP_PRICES_LIGHTNING_ROD(Integer.class, "shop.prices.lightning_rod"),
|
||||||
SHOP_PRICES_FIRE_BALL(Integer.class, "shop.prices.fire_ball"),
|
SHOP_PRICES_FIRE_BALL(Integer.class, "shop.prices.fire_ball"),
|
||||||
SHOP_PRICES_RIDEABLE_PEARL(Integer.class, "shop.prices.rideable_pearl"),
|
SHOP_PRICES_RIDEABLE_PEARL(Integer.class, "shop.prices.rideable_pearl"),
|
||||||
|
SHOP_PRICES_STACKING_POTATO(Integer.class, "shop.prices.stacking_potato"),
|
||||||
//
|
//
|
||||||
ADMINLIST_CLEAN_THESHOLD_HOURS(Integer.class, "adminlist.clean_threshold_hours"),
|
ADMINLIST_CLEAN_THESHOLD_HOURS(Integer.class, "adminlist.clean_threshold_hours"),
|
||||||
ADMINLIST_CONSOLE_IS_SENIOR(Boolean.class, "adminlist.console_is_senior"),
|
ADMINLIST_CONSOLE_IS_SENIOR(Boolean.class, "adminlist.console_is_senior"),
|
||||||
|
@ -11,8 +11,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||||
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
@ -30,12 +28,14 @@ import org.bukkit.entity.Firework;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
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;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -98,6 +98,55 @@ public class ItemFun extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerEntityInteract(PlayerInteractEntityEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
Entity entity = event.getRightClicked();
|
||||||
|
|
||||||
|
if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO) || entity.getType().equals(EntityType.PLAYER))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.STACKING_POTATO, player.getInventory().getItemInMainHand(), plugin.sh.getStackingPotato()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.addPassenger(entity);
|
||||||
|
player.sendMessage("Stacked " + entity.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onEntityDamage(EntityDamageByEntityEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
|
if (entity instanceof Player || !(event.getDamager() instanceof Player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player)event.getDamager();
|
||||||
|
|
||||||
|
if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.STACKING_POTATO, player.getInventory().getItemInMainHand(), plugin.sh.getStackingPotato()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
entity.addPassenger(player);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteractEvent(PlayerInteractEvent event)
|
public void onPlayerInteractEvent(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
@ -112,130 +161,6 @@ public class ItemFun extends FreedomService
|
|||||||
|
|
||||||
switch (event.getMaterial())
|
switch (event.getMaterial())
|
||||||
{
|
{
|
||||||
case TROPICAL_FISH:
|
|
||||||
{
|
|
||||||
final int RADIUS_HIT = 5;
|
|
||||||
final int STRENGTH = 4;
|
|
||||||
|
|
||||||
if (!plugin.al.isSeniorAdmin(player))
|
|
||||||
{
|
|
||||||
final StringBuilder msg = new StringBuilder();
|
|
||||||
final char[] chars = ("That's clownery, luv").toCharArray();
|
|
||||||
for (char c : chars)
|
|
||||||
{
|
|
||||||
msg.append(FUtil.randomChatColor()).append(c);
|
|
||||||
}
|
|
||||||
player.sendMessage(msg.toString());
|
|
||||||
|
|
||||||
player.getEquipment().getItemInMainHand().setType(Material.POTATO);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
boolean didHit = false;
|
|
||||||
|
|
||||||
final Location playerLoc = player.getLocation();
|
|
||||||
final Vector playerLocVec = playerLoc.toVector();
|
|
||||||
|
|
||||||
final List<Player> players = player.getWorld().getPlayers();
|
|
||||||
for (final Player target : players)
|
|
||||||
{
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location targetPos = target.getLocation();
|
|
||||||
final Vector targetPosVec = targetPos.toVector();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (targetPosVec.distanceSquared(playerLocVec) < (RADIUS_HIT * RADIUS_HIT))
|
|
||||||
{
|
|
||||||
FUtil.setFlying(player, false);
|
|
||||||
target.setVelocity(targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH));
|
|
||||||
didHit = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (didHit)
|
|
||||||
{
|
|
||||||
final Sound[] sounds = Sound.values();
|
|
||||||
for (Sound sound : sounds)
|
|
||||||
{
|
|
||||||
if (sound.toString().contains("HIT"))
|
|
||||||
{
|
|
||||||
playerLoc.getWorld().playSound(randomOffset(playerLoc, 5.0), sound, 100.0f, randomDoubleRange(0.5, 2.0).floatValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case CARROT:
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean() || !plugin.al.isSeniorAdmin(player) || plugin.wr.doRestrict(player))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location location = player.getLocation().clone();
|
|
||||||
|
|
||||||
Vector playerPosition = location.toVector().add(new Vector(0.0, 1.65, 0.0));
|
|
||||||
Vector playerDirection = location.getDirection().normalize();
|
|
||||||
|
|
||||||
double distance = 150.0;
|
|
||||||
Block targetBlock = DepreciationAggregator.getTargetBlock(player, null, Math.round((float)distance));
|
|
||||||
if (targetBlock != null)
|
|
||||||
{
|
|
||||||
distance = location.distance(targetBlock.getLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Block> affected = new ArrayList<>();
|
|
||||||
|
|
||||||
Block lastBlock = null;
|
|
||||||
for (double offset = 0.0; offset <= distance; offset += (distance / 25.0))
|
|
||||||
{
|
|
||||||
Block block = playerPosition.clone().add(playerDirection.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
|
|
||||||
|
|
||||||
if (!block.equals(lastBlock))
|
|
||||||
{
|
|
||||||
if (block.isEmpty())
|
|
||||||
{
|
|
||||||
affected.add(block);
|
|
||||||
block.setType(Material.TNT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lastBlock = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
for (Block tntBlock : affected)
|
|
||||||
{
|
|
||||||
TNTPrimed tnt = tntBlock.getWorld().spawn(tntBlock.getLocation(), TNTPrimed.class);
|
|
||||||
tnt.setFuseTicks(5);
|
|
||||||
tntBlock.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskLater(plugin, 30L);
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BONE:
|
case BONE:
|
||||||
{
|
{
|
||||||
if (!fPlayer.mobThrowerEnabled())
|
if (!fPlayer.mobThrowerEnabled())
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.fun;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class MobStacker extends FreedomService
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onStart()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onEntityDamage(EntityDamageByEntityEvent event)
|
|
||||||
{
|
|
||||||
if (event.getEntity() instanceof Player || !(event.getDamager() instanceof Player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player attacker = (Player)event.getDamager();
|
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(attacker))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack item = attacker.getInventory().getItemInMainHand();
|
|
||||||
|
|
||||||
if (item != null && item.getType().equals(Material.POTATO))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
attacker.addPassenger(event.getEntity());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,13 +6,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.rayzr522.jsonmessage.JSONMessage;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.boss.BarColor;
|
||||||
|
import org.bukkit.boss.BarStyle;
|
||||||
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -32,12 +34,22 @@ public class Shop extends FreedomService
|
|||||||
public String reactionString = "";
|
public String reactionString = "";
|
||||||
public Date reactionStartTime;
|
public Date reactionStartTime;
|
||||||
public final int coinsPerReactionWin = ConfigEntry.SHOP_REACTIONS_COINS_PER_WIN.getInteger();
|
public final int coinsPerReactionWin = ConfigEntry.SHOP_REACTIONS_COINS_PER_WIN.getInteger();
|
||||||
|
public final String prefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] ";
|
||||||
|
public BukkitTask countdownTask;
|
||||||
|
private BossBar countdownBar = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
|
startReactionTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startReactionTimer()
|
||||||
|
{
|
||||||
|
|
||||||
long interval = ConfigEntry.SHOP_REACTIONS_INTERVAL.getInteger() * 20L;
|
long interval = ConfigEntry.SHOP_REACTIONS_INTERVAL.getInteger() * 20L;
|
||||||
|
|
||||||
reactions = new BukkitRunnable()
|
reactions = new BukkitRunnable()
|
||||||
@ -45,22 +57,72 @@ public class Shop extends FreedomService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
|
{
|
||||||
|
startReaction();
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forceStartReaction()
|
||||||
|
{
|
||||||
|
reactions.cancel();
|
||||||
|
startReaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startReaction()
|
||||||
{
|
{
|
||||||
reactionString = FUtil.randomString(ConfigEntry.SHOP_REACTIONS_STRING_LENGTH.getInteger());
|
reactionString = FUtil.randomString(ConfigEntry.SHOP_REACTIONS_STRING_LENGTH.getInteger());
|
||||||
|
|
||||||
|
FUtil.bcastMsg(prefix + ChatColor.AQUA + "Enter the code above to win " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.AQUA + " coins!", false);
|
||||||
|
|
||||||
|
reactionStartTime = new Date();
|
||||||
|
|
||||||
|
countdownBar = server.createBossBar(reactionString, BarColor.GREEN, BarStyle.SOLID);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
String reactionMessage = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] "
|
countdownBar.addPlayer(player);
|
||||||
+ ChatColor.AQUA + "Hover over this message or click on it and type the "
|
}
|
||||||
+ ChatColor.AQUA + "string to win " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.AQUA + " coins!";
|
countdownBar.setVisible(true);
|
||||||
JSONMessage.create(reactionMessage)
|
countdownTask = new BukkitRunnable()
|
||||||
.tooltip(ChatColor.DARK_AQUA + reactionString)
|
{
|
||||||
.runCommand("/reactionbar")
|
double seconds = 30;
|
||||||
.send(player);
|
double max = seconds;
|
||||||
reactionStartTime = new Date();
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if ((seconds -= 1) == 0)
|
||||||
|
{
|
||||||
|
endReaction(null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
countdownBar.setProgress(seconds / max);
|
||||||
|
if (!countdownBar.getColor().equals(BarColor.YELLOW) && seconds / max <= 0.25)
|
||||||
|
{
|
||||||
|
countdownBar.setColor(BarColor.YELLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, interval, interval);
|
|
||||||
}
|
}
|
||||||
|
}.runTaskTimer(plugin, 0, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endReaction(String winner)
|
||||||
|
{
|
||||||
|
countdownTask.cancel();
|
||||||
|
countdownBar.removeAll();
|
||||||
|
countdownBar = null;
|
||||||
|
reactionString = "";
|
||||||
|
|
||||||
|
if (winner != null)
|
||||||
|
{
|
||||||
|
Date currentTime = new Date();
|
||||||
|
long seconds = (currentTime.getTime() - reactionStartTime.getTime()) / 1000;
|
||||||
|
FUtil.bcastMsg(prefix + ChatColor.GREEN + winner + ChatColor.AQUA + " won in " + seconds + " seconds!", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.bcastMsg(prefix + ChatColor.RED + "No one reacted fast enough", false);
|
||||||
|
startReactionTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -167,6 +229,16 @@ public class Shop extends FreedomService
|
|||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getStackingPotato()
|
||||||
|
{
|
||||||
|
ItemStack itemStack = new ItemStack(Material.POTATO);
|
||||||
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
itemMeta.setDisplayName(ChatColor.YELLOW + "Stacking Potato");
|
||||||
|
itemMeta.setLore(Arrays.asList(ChatColor.GREEN + "Left click to ride a mob, right click to put a mob on your head."));
|
||||||
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean canAfford(int price, int coins)
|
public boolean canAfford(int price, int coins)
|
||||||
{
|
{
|
||||||
@ -264,6 +336,10 @@ public class Shop extends FreedomService
|
|||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GREEN + "Run /rideablepearl to get one!");
|
player.sendMessage(ChatColor.GREEN + "Run /rideablepearl to get one!");
|
||||||
}
|
}
|
||||||
|
else if (shopItem.equals(ShopItem.STACKING_POTATO))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GREEN + "Run /stackingpotato to get one!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,17 +10,18 @@ public enum ShopItem
|
|||||||
GRAPPLING_HOOK("Grappling Hook", Material.FISHING_ROD, 10, ConfigEntry.SHOP_PRICES_GRAPPLING_HOOK, ChatColor.GREEN, "grapplingHook"),
|
GRAPPLING_HOOK("Grappling Hook", Material.FISHING_ROD, 10, ConfigEntry.SHOP_PRICES_GRAPPLING_HOOK, ChatColor.GREEN, "grapplingHook"),
|
||||||
LIGHTNING_ROD("Lightning Rod", Material.BLAZE_ROD, 12, ConfigEntry.SHOP_PRICES_LIGHTNING_ROD, ChatColor.LIGHT_PURPLE, "lightningRod"),
|
LIGHTNING_ROD("Lightning Rod", Material.BLAZE_ROD, 12, ConfigEntry.SHOP_PRICES_LIGHTNING_ROD, ChatColor.LIGHT_PURPLE, "lightningRod"),
|
||||||
FIRE_BALL("Fire Ball", Material.FIRE_CHARGE, 14, ConfigEntry.SHOP_PRICES_FIRE_BALL, ChatColor.RED, "fireBall"),
|
FIRE_BALL("Fire Ball", Material.FIRE_CHARGE, 14, ConfigEntry.SHOP_PRICES_FIRE_BALL, ChatColor.RED, "fireBall"),
|
||||||
RIDEABLE_PEARL("Rideable Ender Pearl", Material.ENDER_PEARL, 16, ConfigEntry.SHOP_PRICES_RIDEABLE_PEARL, ChatColor.DARK_PURPLE, "rideablePearl");
|
RIDEABLE_PEARL("Rideable Ender Pearl", Material.ENDER_PEARL, 16, ConfigEntry.SHOP_PRICES_RIDEABLE_PEARL, ChatColor.DARK_PURPLE, "rideablePearl"),
|
||||||
|
STACKING_POTATO("Stacking Potato", Material.POTATO, 22, ConfigEntry.SHOP_PRICES_STACKING_POTATO, ChatColor.YELLOW, "stackingPotato");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Shop GUI Layout:
|
Shop GUI Layout:
|
||||||
|
|
||||||
Dimensions: 9x4 = 36
|
Dimensions: 9x4 = 36
|
||||||
Key: g = Grappling Hook, l = Lightning Rod, f = Fire Ball, r = Rideable Ender Pearl, $ = Coins}
|
Key: g = Grappling Hook, l = Lightning Rod, f = Fire Ball, r = Rideable Ender Pearl, S = Stacking Potato $ = Coins}
|
||||||
|
|
||||||
---------
|
---------
|
||||||
-g-l-f-r-
|
-g-l-f-r-
|
||||||
---------
|
----s----
|
||||||
--------$
|
--------$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -107,6 +107,9 @@ shop:
|
|||||||
# How much time (in seconds) before a new reaction prompt is made
|
# How much time (in seconds) before a new reaction prompt is made
|
||||||
interval: 300
|
interval: 300
|
||||||
|
|
||||||
|
# How much time do players have to react
|
||||||
|
time: 30
|
||||||
|
|
||||||
# How many coins do winners get?
|
# How many coins do winners get?
|
||||||
coins_per_win: 5
|
coins_per_win: 5
|
||||||
|
|
||||||
@ -119,6 +122,7 @@ shop:
|
|||||||
lightning_rod: 1000
|
lightning_rod: 1000
|
||||||
fire_ball: 500
|
fire_ball: 500
|
||||||
rideable_pearl: 700
|
rideable_pearl: 700
|
||||||
|
stacking_potato: 300
|
||||||
|
|
||||||
# Admin list
|
# Admin list
|
||||||
adminlist:
|
adminlist:
|
||||||
@ -155,12 +159,6 @@ social_links:
|
|||||||
Website: 'https://totalfreedom.me/'
|
Website: 'https://totalfreedom.me/'
|
||||||
Discord: 'https://discordapp.com/invite/XXjmAmV/'
|
Discord: 'https://discordapp.com/invite/XXjmAmV/'
|
||||||
|
|
||||||
donation:
|
|
||||||
proboards_url: ''
|
|
||||||
donator_group_id: ''
|
|
||||||
session_id: ''
|
|
||||||
csrf_token: ''
|
|
||||||
|
|
||||||
# Blocking certain events
|
# Blocking certain events
|
||||||
allow:
|
allow:
|
||||||
fire_place: false
|
fire_place: false
|
||||||
|
Loading…
Reference in New Issue
Block a user