April Fools update
This commit is contained in:
parent
50c38dc467
commit
ed35d2a992
@ -0,0 +1,196 @@
|
||||
package mineplex.core.aprilfools;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseCow;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class AprilFoolsManager extends MiniPlugin
|
||||
{
|
||||
public static AprilFoolsManager Instance;
|
||||
|
||||
private boolean _enabled;
|
||||
private DisguiseManager _disguiseManager;
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
private HashSet<Player> _disguised = new HashSet<Player>();
|
||||
|
||||
protected AprilFoolsManager(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager)
|
||||
{
|
||||
super("April Fools", plugin);
|
||||
|
||||
_disguiseManager = disguiseManager;
|
||||
_clientManager = clientManager;
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
_enabled = (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1);
|
||||
}
|
||||
|
||||
public static void Initialize(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager)
|
||||
{
|
||||
Instance = new AprilFoolsManager(plugin, clientManager, disguiseManager);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void chatAdd(AsyncPlayerChatEvent event)
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
String[] words = event.getMessage().split(" ");
|
||||
|
||||
String out = "";
|
||||
for (String word : words)
|
||||
{
|
||||
//Prefix
|
||||
if (Math.random() > 0.9)
|
||||
{
|
||||
out += "moo";
|
||||
|
||||
for (int i=0 ; i<UtilMath.r(2) ; i++)
|
||||
out += "o";
|
||||
|
||||
out += " " + word + " ";
|
||||
|
||||
}
|
||||
|
||||
//Suffix
|
||||
else if (Math.random() > 0.9)
|
||||
{
|
||||
out += word + " ";
|
||||
|
||||
out += "moo";
|
||||
|
||||
for (int i=0 ; i<UtilMath.r(2) ; i++)
|
||||
out += "o";
|
||||
|
||||
out += " ";
|
||||
}
|
||||
|
||||
//Swap
|
||||
else if (Math.random() > 0.99)
|
||||
{
|
||||
out += "moo";
|
||||
|
||||
for (int i=3 ; i<word.length() ; i++)
|
||||
out += "o";
|
||||
|
||||
out += " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
out += word + " ";
|
||||
}
|
||||
}
|
||||
|
||||
event.setMessage(out);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCow(UpdateEvent event)
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
//Disguise
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (_disguiseManager.getDisguise(player) != null)
|
||||
continue;
|
||||
|
||||
//Disguise
|
||||
DisguiseCow disguise = new DisguiseCow(player);
|
||||
disguise.setName(getName(player), _clientManager.Get(player).GetRank());
|
||||
disguise.setCustomNameVisible(true);
|
||||
_disguiseManager.disguise(disguise);
|
||||
|
||||
_disguised.add(player);
|
||||
}
|
||||
|
||||
//Moo
|
||||
Iterator<Player> disguiseIter = _disguised.iterator();
|
||||
while (disguiseIter.hasNext())
|
||||
{
|
||||
Player player = disguiseIter.next();
|
||||
|
||||
if (!player.isValid() || !player.isOnline() ||
|
||||
_disguiseManager.getDisguise(player) == null ||
|
||||
!(_disguiseManager.getDisguise(player) instanceof DisguiseCow))
|
||||
{
|
||||
disguiseIter.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Math.random() > 0.8)
|
||||
{
|
||||
player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, (float)Math.random() + 0.5f, (float)Math.random() + 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
public String getName(Player player)
|
||||
{
|
||||
//Name
|
||||
int index = 0;
|
||||
boolean hitVowel = false;
|
||||
for (int i=0 ; i<player.getName().length()-2 && i<5 ; i++)
|
||||
{
|
||||
//Detect vowel ;o
|
||||
if (player.getName().toLowerCase().charAt(i) == 'a' ||
|
||||
player.getName().toLowerCase().charAt(i) == 'e' ||
|
||||
player.getName().toLowerCase().charAt(i) == 'i' ||
|
||||
player.getName().toLowerCase().charAt(i) == 'o' ||
|
||||
player.getName().toLowerCase().charAt(i) == 'u')
|
||||
{
|
||||
hitVowel = true;
|
||||
}
|
||||
//Post vowel consonant - stop here
|
||||
else if (hitVowel)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
index = i+1;
|
||||
}
|
||||
|
||||
String name = "Moo" + player.getName().substring(index, player.getName().length());
|
||||
|
||||
if (name.length() > 16)
|
||||
name = name.substring(0, 16);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean b)
|
||||
{
|
||||
_enabled = b;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import mineplex.core.TablistFix;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
@ -129,6 +130,8 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
//new Replay(this, packetHandler);
|
||||
new PersonalServerManager(this, clientManager);
|
||||
|
||||
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
|
||||
|
||||
CombatManager combatManager = new CombatManager(this);
|
||||
|
||||
ProjectileManager throwManager = new ProjectileManager(this);
|
||||
|
@ -46,6 +46,7 @@ import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -514,11 +515,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
String playerName = player.getName();
|
||||
|
||||
// April Fools
|
||||
Calendar c = Calendar.getInstance();
|
||||
if (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1)
|
||||
{
|
||||
playerName = "Notch";
|
||||
}
|
||||
if (AprilFoolsManager.Instance.isActive())
|
||||
playerName = AprilFoolsManager.Instance.getName(player);
|
||||
|
||||
//Public Message
|
||||
if (_clientManager.Get(player).GetRank() != Rank.LEGEND)
|
||||
@ -530,7 +528,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
player.getWorld().playSound(player.getEyeLocation(), Sound.WITHER_SPAWN, 2f, 1f);
|
||||
}
|
||||
|
||||
|
||||
//Teleport
|
||||
player.teleport(GetSpawn().add(0, 10, 0));
|
||||
|
||||
@ -631,6 +628,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String playerName = player.getName();
|
||||
|
||||
// April Fools
|
||||
if (AprilFoolsManager.Instance.isActive())
|
||||
playerName = AprilFoolsManager.Instance.getName(player);
|
||||
|
||||
Rank rank = GetClients().Get(player).GetRank();
|
||||
|
||||
@ -656,7 +658,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
event.getRecipients().clear();
|
||||
|
||||
event.setMessage(event.getMessage().substring(1, event.getMessage().length()));
|
||||
event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "%1$s " + C.cPurple + "%2$s");
|
||||
event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s");
|
||||
|
||||
for (String name : party.GetPlayers())
|
||||
{
|
||||
@ -685,7 +687,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
}
|
||||
|
||||
event.setMessage(event.getMessage());
|
||||
event.setFormat(levelStr + rankStr + C.cYellow + "%1$s " + C.cWhite + "%2$s");
|
||||
event.setFormat(levelStr + rankStr + C.cYellow + playerName + " " + C.cWhite + "%2$s");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (Manager.getPreferences().Get(player).HubForcefield)
|
||||
if (Manager.getPreferences().Get(player).HubForcefield && Manager.GetClients().Get(player).GetRank().Has(Rank.ADMIN))
|
||||
{
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ import mineplex.core.CustomTagFix;
|
||||
import mineplex.core.TablistFix;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.blood.Blood;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
@ -135,6 +136,8 @@ public class Arcade extends JavaPlugin
|
||||
new CustomTagFix(this, packetHandler);
|
||||
new TablistFix(this);
|
||||
|
||||
AprilFoolsManager.Initialize(this, _clientManager, disguiseManager);
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
||||
|
@ -33,6 +33,7 @@ import org.bukkit.util.Vector;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.blood.Blood;
|
||||
import mineplex.core.chat.Chat;
|
||||
@ -602,8 +603,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
@EventHandler
|
||||
public void MessageJoin(PlayerJoinEvent event)
|
||||
{
|
||||
String name = event.getPlayer().getName();
|
||||
|
||||
// April Fools
|
||||
if (AprilFoolsManager.Instance.isActive())
|
||||
name = AprilFoolsManager.Instance.getName(event.getPlayer());
|
||||
|
||||
if (_game != null && _game.AnnounceJoinQuit)
|
||||
event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + event.getPlayer().getName()));
|
||||
event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + name));
|
||||
|
||||
else
|
||||
event.setJoinMessage(null);
|
||||
@ -612,8 +619,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
@EventHandler
|
||||
public void MessageQuit(PlayerQuitEvent event)
|
||||
{
|
||||
String name = event.getPlayer().getName();
|
||||
|
||||
// April Fools
|
||||
if (AprilFoolsManager.Instance.isActive())
|
||||
name = AprilFoolsManager.Instance.getName(event.getPlayer());
|
||||
|
||||
if (_game == null || _game.AnnounceJoinQuit)
|
||||
event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + event.getPlayer().getName()));
|
||||
event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + name));
|
||||
else
|
||||
event.setQuitMessage(null);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.champions;
|
||||
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
|
@ -2,6 +2,7 @@ package nautilus.game.arcade.managers;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -46,6 +47,11 @@ public class GameChatManager implements Listener
|
||||
return;
|
||||
|
||||
Player sender = event.getPlayer();
|
||||
String senderName = sender.getName();
|
||||
|
||||
// April Fools
|
||||
if (AprilFoolsManager.Instance.isActive())
|
||||
senderName = AprilFoolsManager.Instance.getName(sender);
|
||||
|
||||
//Dead Prefix
|
||||
String dead = "";
|
||||
@ -100,7 +106,7 @@ public class GameChatManager implements Listener
|
||||
event.getRecipients().clear();
|
||||
|
||||
event.setMessage(event.getMessage().substring(1, event.getMessage().length()));
|
||||
event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "%1$s " + C.cPurple + "%2$s");
|
||||
event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + senderName + " " + C.cPurple + "%2$s");
|
||||
|
||||
event.getRecipients().addAll(party.GetPlayersOnline());
|
||||
|
||||
@ -109,7 +115,7 @@ public class GameChatManager implements Listener
|
||||
}
|
||||
|
||||
//Base Format
|
||||
event.setFormat(dead + levelStr + rankStr + Manager.GetColor(sender) + "%1$s " + ChatColor.WHITE + "%2$s");
|
||||
event.setFormat(dead + levelStr + rankStr + Manager.GetColor(sender) + senderName + " " + ChatColor.WHITE + "%2$s");
|
||||
|
||||
//Public/Private (Not If Player Dead)
|
||||
if (Manager.GetGame() != null && Manager.GetGame().GetState() == GameState.Live)
|
||||
@ -125,13 +131,13 @@ public class GameChatManager implements Listener
|
||||
if (event.getMessage().charAt(0) == '@')
|
||||
{
|
||||
event.setMessage(event.getMessage().substring(1, event.getMessage().length()));
|
||||
event.setFormat(C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s");
|
||||
event.setFormat(C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s");
|
||||
}
|
||||
//All Chat
|
||||
else
|
||||
{
|
||||
globalMessage = true;
|
||||
event.setFormat(dead + levelStr + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s");
|
||||
event.setFormat(dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class HalloweenManager implements Listener
|
||||
public class HolidayManager implements Listener
|
||||
{
|
||||
ArcadeManager Manager;
|
||||
|
||||
@ -40,7 +40,7 @@ public class HalloweenManager implements Listener
|
||||
|
||||
public long _lastSpawn = System.currentTimeMillis();
|
||||
|
||||
public HalloweenManager(ArcadeManager manager)
|
||||
public HolidayManager(ArcadeManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
|
||||
@ -61,29 +61,29 @@ public class HalloweenManager implements Listener
|
||||
if (event.getType() == UpdateType.TICK)
|
||||
return;
|
||||
|
||||
Iterator<Block> pumpkinIterator = _active.iterator();
|
||||
Iterator<Block> blockIterator = _active.iterator();
|
||||
|
||||
while (pumpkinIterator.hasNext())
|
||||
while (blockIterator.hasNext())
|
||||
{
|
||||
Block pumpkin = pumpkinIterator.next();
|
||||
Block block = blockIterator.next();
|
||||
|
||||
if (pumpkin.getType() != Material.PUMPKIN && pumpkin.getType() != Material.JACK_O_LANTERN)
|
||||
if (block.getType() != Material.PUMPKIN && block.getType() != Material.JACK_O_LANTERN)
|
||||
{
|
||||
pumpkinBreak(pumpkin);
|
||||
pumpkinIterator.remove();
|
||||
pumpkinBreak(block);
|
||||
blockIterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.FLAME, pumpkin.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4);
|
||||
UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4);
|
||||
if (Math.random() > 0.90)
|
||||
{
|
||||
if (pumpkin.getType() == Material.PUMPKIN)
|
||||
if (block.getType() == Material.PUMPKIN)
|
||||
{
|
||||
pumpkin.setType(Material.JACK_O_LANTERN);
|
||||
block.setType(Material.JACK_O_LANTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
pumpkin.setType(Material.PUMPKIN);
|
||||
block.setType(Material.PUMPKIN);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user