Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex into clans/alpha
This commit is contained in:
commit
c873b6b886
3
.gitignore
vendored
3
.gitignore
vendored
@ -52,3 +52,6 @@ zSotanna2
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock
|
||||
/Pocket
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_
|
||||
/RemoteSystemsTempFiles
|
||||
/.recommenders/caches
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" hash="1486084220">
|
||||
<component name="DataSourceManagerImpl" format="xml" hash="3221233088">
|
||||
<data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e">
|
||||
<driver-ref>mysql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.common.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
@ -117,6 +118,15 @@ public class UtilMath
|
||||
return num < min ? min : (num > max ? max : num);
|
||||
}
|
||||
|
||||
public static List<Integer> digits(int i) {
|
||||
List<Integer> digits = new ArrayList<Integer>();
|
||||
while(i > 0) {
|
||||
digits.add(i % 10);
|
||||
i /= 10;
|
||||
}
|
||||
return digits;
|
||||
}
|
||||
|
||||
public static double random(double min, double max)
|
||||
{
|
||||
min = Math.abs(min);
|
||||
|
@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
|
||||
public class UtilText
|
||||
{
|
||||
private static HashMap<Character, Integer> _characters = new HashMap<Character, Integer>();
|
||||
private static HashMap<Character, BufferedImage> _characterImages = new HashMap<Character, BufferedImage>();
|
||||
|
||||
static
|
||||
{
|
||||
@ -297,14 +298,14 @@ public class UtilText
|
||||
{
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
|
||||
//Ignore lines with #
|
||||
// Ignore lines with #
|
||||
if (string.startsWith("#"))
|
||||
{
|
||||
strings.add(string.substring(1, string.length()));
|
||||
return strings;
|
||||
}
|
||||
|
||||
//Empty
|
||||
// Empty
|
||||
if (string.equals("") || string.equals(" "))
|
||||
{
|
||||
strings.add(string);
|
||||
@ -454,35 +455,63 @@ public class UtilText
|
||||
|
||||
private static void grab(Character character, BufferedImage image, int imageX, int imageY)
|
||||
{
|
||||
BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8);
|
||||
|
||||
int width = 8;
|
||||
|
||||
if (character == ' ')
|
||||
{
|
||||
_characters.put(character, 3);
|
||||
return;
|
||||
width = 3;
|
||||
}
|
||||
|
||||
for (int x = 0; x < 8; x++)
|
||||
else
|
||||
{
|
||||
boolean isTransparentLine = true;
|
||||
|
||||
for (int y = 0; y < 8; y++)
|
||||
for (int x = 0; x < 8; x++)
|
||||
{
|
||||
int pixel = image.getRGB(imageX + x, imageY + y);
|
||||
boolean isTransparentLine = true;
|
||||
|
||||
if ((pixel >> 24) != 0x00)
|
||||
for (int y = 0; y < 8; y++)
|
||||
{
|
||||
isTransparentLine = false;
|
||||
int pixel = image.getRGB(imageX + x, imageY + y);
|
||||
|
||||
if ((pixel >> 24) != 0x00)
|
||||
{
|
||||
isTransparentLine = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isTransparentLine)
|
||||
{
|
||||
width = x + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isTransparentLine)
|
||||
{
|
||||
_characters.put(character, x);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_characters.put(character, 8);
|
||||
newImage = newImage.getSubimage(0, 0, width, 8);
|
||||
|
||||
_characterImages.put(character, newImage);
|
||||
_characters.put(character, width);
|
||||
}
|
||||
|
||||
public static int getLength(char character)
|
||||
{
|
||||
if (!_characters.containsKey(character))
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
return _characters.get(character);
|
||||
}
|
||||
|
||||
public static BufferedImage getImage(char character)
|
||||
{
|
||||
if (!_characterImages.containsKey(character))
|
||||
{
|
||||
character = '?';
|
||||
}
|
||||
|
||||
return _characterImages.get(character);
|
||||
}
|
||||
|
||||
public static boolean isStringSimilar(String newString, String oldString, float matchRequirement)
|
||||
|
@ -128,14 +128,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
if (client == null)
|
||||
{
|
||||
if (Bukkit.getPlayer(name) != null)
|
||||
{
|
||||
client = new CoreClient(Bukkit.getPlayer(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
client = new CoreClient(name);
|
||||
}
|
||||
client = new CoreClient(name);
|
||||
}
|
||||
|
||||
return client;
|
||||
|
@ -81,7 +81,7 @@ public class StatDisplay
|
||||
formattedStats[i] = gameDisplay.getName() + "." + stats[i];
|
||||
}
|
||||
|
||||
return new StatDisplay(name, true, formattedStats);
|
||||
return new StatDisplay(name, true, false, formattedStats);
|
||||
}
|
||||
|
||||
public static final StatDisplay WINS = new StatDisplay("Wins");
|
||||
|
@ -440,6 +440,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
incrementDailyStreak(player);
|
||||
awardBonus(player, amount);
|
||||
updateCreeperVisual(player, true, C.cAqua);
|
||||
UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!"));
|
||||
|
||||
_statsManager.incrementStat(player, "Global.DailyReward", 1);
|
||||
}
|
||||
@ -481,6 +482,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
awardBonus(player, getRankBonusAmount(player));
|
||||
updateCreeperVisual(player, true, C.cAqua);
|
||||
UtilPlayer.message(player, F.main("Carl", "Come back next month for more!"));
|
||||
}
|
||||
|
||||
result.run(aBoolean);
|
||||
@ -814,9 +816,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_statsManager.incrementStat(player, "Global.ExpEarned", experience);
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(experience + " Experience")));
|
||||
}
|
||||
|
||||
UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!"));
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -48,10 +48,15 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
||||
return new PlayerCustomData(_repository);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData(String name, int accountId)
|
||||
public void saveAsync(Player player)
|
||||
{
|
||||
_repository.saveData(name, accountId);
|
||||
final int accountId = getClientManager().getAccountId(player);
|
||||
final String name = player.getName();
|
||||
|
||||
if (accountId == -1)
|
||||
return;
|
||||
|
||||
runAsync(() -> _repository.saveData(name, accountId));
|
||||
}
|
||||
|
||||
public CorePlayer getCorePlayer(Player player)
|
||||
|
@ -27,10 +27,11 @@ public abstract class MineplexPlayer
|
||||
return "";
|
||||
}
|
||||
|
||||
public void put(String key, int data)
|
||||
public void put(String key, int data, boolean save)
|
||||
{
|
||||
key = getKeyPrefix() + key;
|
||||
_customDataManager.Get(getPlayer()).setData(key, data);
|
||||
if (save) _customDataManager.saveAsync(_player);
|
||||
}
|
||||
|
||||
public int get(String key)
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.customdata.repository;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -71,20 +72,20 @@ public class CustomDataRepository extends RepositoryBase
|
||||
{
|
||||
PlayerCustomData data = _customDataManager.Get(name);
|
||||
|
||||
for (CustomData cd : data.getDataMap().keySet())
|
||||
for (Map.Entry<CustomData, Integer> entry : data.getDataMap().entrySet())
|
||||
{
|
||||
if (executeUpdate(
|
||||
UPDATE_DATA,
|
||||
new ColumnInt("data", data.getDataMap().get(cd)),
|
||||
new ColumnInt("data", entry.getValue()),
|
||||
new ColumnInt("account", accountId),
|
||||
new ColumnInt("customData", cd.getId())) < 1)
|
||||
new ColumnInt("customData", entry.getKey().getId())) < 1)
|
||||
{
|
||||
// Not already in the DB
|
||||
executeUpdate(
|
||||
INSERT_DATA,
|
||||
new ColumnInt("account", accountId),
|
||||
new ColumnInt("customData", cd.getId()),
|
||||
new ColumnInt("data", data.getDataMap().get(cd))
|
||||
new ColumnInt("customData", entry.getKey().getId()),
|
||||
new ColumnInt("data", entry.getValue())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package mineplex.core.disguise;
|
||||
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
public class DisguisePlayerBean implements Data
|
||||
{
|
||||
private int _accountID;
|
||||
private String _disguisedPlayer;
|
||||
private String _playerName;
|
||||
public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs)
|
||||
{
|
||||
this._accountID = playerAccountID;
|
||||
this._disguisedPlayer = disguiseAs;
|
||||
this._playerName = playerName;
|
||||
|
||||
}
|
||||
public int getAccountID()
|
||||
{
|
||||
return _accountID;
|
||||
}
|
||||
public String getDisguisedPlayer()
|
||||
{
|
||||
return _disguisedPlayer;
|
||||
}
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
@Override
|
||||
public String getDataId()
|
||||
{
|
||||
return _accountID+_playerName;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package mineplex.core.disguise;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class PlayerDisguiseManager extends MiniPlugin
|
||||
{
|
||||
private CoreClientManager _clients;
|
||||
private RedisDataRepository<DisguisePlayerBean> _redis;
|
||||
public PlayerDisguiseManager(JavaPlugin plugin, CoreClientManager clients)
|
||||
{
|
||||
super("Player Disguise Manager", plugin);
|
||||
this._clients = clients;
|
||||
|
||||
_redis = new RedisDataRepository<DisguisePlayerBean>(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisguisedPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
CoreClient client = _clients.Get(event.getPlayer());
|
||||
if(client.isDisguised())
|
||||
{
|
||||
_redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.GetPlayerName(), client.getDisguisedAs()), 60*60*12); // 12 hours
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisguisedPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
CoreClient client = _clients.Get(event.getPlayer());
|
||||
|
||||
if(!client.GetRank().has(Rank.JNR_DEV) && client.GetRank() != Rank.YOUTUBE_SMALL && client.GetRank() != Rank.TWITCH && client.GetRank() != Rank.YOUTUBE)
|
||||
return;
|
||||
|
||||
if(_redis.elementExists(client.getAccountId()+client.GetPlayerName()))
|
||||
{
|
||||
DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName());
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer()));
|
||||
event.setJoinMessage("");
|
||||
}
|
||||
}
|
||||
}.runTaskLater(getPlugin(), 7);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerUndisguise(PlayerUndisguiseEvent event)
|
||||
{
|
||||
CoreClient client = _clients.Get(event.getPlayer());
|
||||
_redis.removeElement(client.getAccountId()+client.GetPlayerName());
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package mineplex.core.disguise;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerUndisguiseEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player _player;
|
||||
public PlayerUndisguiseEvent(Player disguisee)
|
||||
{
|
||||
this._player = disguisee;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -2,14 +2,9 @@ package mineplex.core.map;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -20,86 +15,6 @@ import org.bukkit.map.MapView;
|
||||
|
||||
public class MapText
|
||||
{
|
||||
private static HashMap<Character, BufferedImage> _characters = new HashMap<Character, BufferedImage>();
|
||||
|
||||
private void loadCharacters()
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream inputStream = getClass().getResourceAsStream("ascii.png");
|
||||
BufferedImage image = ImageIO.read(inputStream);
|
||||
|
||||
char[] text = new char[]
|
||||
{
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4',
|
||||
'5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
|
||||
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^',
|
||||
'_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
|
||||
't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'
|
||||
};
|
||||
|
||||
int x = 0;
|
||||
int y = 16;
|
||||
|
||||
for (char c : text)
|
||||
{
|
||||
grab(c, image, x, y);
|
||||
|
||||
if (x < 15 * 8)
|
||||
{
|
||||
x += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = 0;
|
||||
y += 8;
|
||||
}
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void grab(Character character, BufferedImage image, int imageX, int imageY)
|
||||
{
|
||||
BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8);
|
||||
|
||||
int width = character == ' ' ? 4 : 0;
|
||||
|
||||
if (width == 0)
|
||||
{
|
||||
for (int x = 0; x < 8; x++)
|
||||
{
|
||||
width++;
|
||||
boolean foundNonTrans = false;
|
||||
|
||||
for (int y = 0; y < 8; y++)
|
||||
{
|
||||
int pixel = newImage.getRGB(x, y);
|
||||
|
||||
if ((pixel >> 24) != 0x00)
|
||||
{
|
||||
foundNonTrans = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundNonTrans)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newImage = newImage.getSubimage(0, 0, width, 8);
|
||||
|
||||
_characters.put(character, newImage);
|
||||
}
|
||||
|
||||
private ArrayList<String> split(String text)
|
||||
{
|
||||
ArrayList<String> returns = new ArrayList<String>();
|
||||
@ -112,7 +27,7 @@ public class MapText
|
||||
|
||||
for (char c : word.toCharArray())
|
||||
{
|
||||
length += _characters.get(c).getWidth();
|
||||
length += UtilText.getImage(c).getWidth();
|
||||
}
|
||||
|
||||
if (lineWidth + length >= 127)
|
||||
@ -133,11 +48,6 @@ public class MapText
|
||||
|
||||
public ItemStack getMap(boolean sendToServer, String... text)
|
||||
{
|
||||
if (_characters.isEmpty())
|
||||
{
|
||||
loadCharacters();
|
||||
}
|
||||
|
||||
BufferedImage image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics g = image.getGraphics();
|
||||
int height = 1;
|
||||
@ -150,13 +60,7 @@ public class MapText
|
||||
|
||||
for (char c : line.toCharArray())
|
||||
{
|
||||
BufferedImage img = _characters.get(c);
|
||||
|
||||
if (img == null)
|
||||
{
|
||||
System.out.print("Error: '" + c + "' has no image associated");
|
||||
continue;
|
||||
}
|
||||
BufferedImage img = UtilText.getImage(c);
|
||||
|
||||
g.drawImage(img, length, height, null);
|
||||
|
||||
|
@ -10,6 +10,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
|
||||
public class AdminCommand extends CommandBase<MessageManager>
|
||||
{
|
||||
@ -53,6 +54,11 @@ public class AdminCommand extends CommandBase<MessageManager>
|
||||
if (!to.equals(caller))
|
||||
UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message);
|
||||
|
||||
if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV))
|
||||
{
|
||||
if(Plugin.GetClientManager().Get(to).isDisguised() || !caller.canSee(to))
|
||||
continue;
|
||||
}
|
||||
staff = true;
|
||||
|
||||
//Sound
|
||||
|
@ -52,8 +52,8 @@ public class NotificationManager extends MiniPlugin
|
||||
// if (event.getType() == UpdateType.MIN_16)
|
||||
// sale();
|
||||
|
||||
if (event.getType() == UpdateType.MIN_08)
|
||||
christmasSale();
|
||||
// if (event.getType() == UpdateType.MIN_08)
|
||||
// christmasSale();
|
||||
}
|
||||
|
||||
private void christmasSale()
|
||||
|
@ -124,7 +124,7 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
buildPreference(indices[1], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
buildPreference(indices[2], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
}
|
||||
else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.YOUTUBE_SMALL)
|
||||
else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH)
|
||||
{
|
||||
int[] indices = UtilUI.getIndicesFor(3, 0, 2);
|
||||
|
||||
@ -132,6 +132,12 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
||||
buildPreference(indices[2], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
}
|
||||
else if (rank == Rank.YOUTUBE_SMALL)
|
||||
{
|
||||
int[] indices = UtilUI.getIndicesFor(2, 0, 2);
|
||||
buildPreference(indices[0], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
||||
buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleHubForcefield(org.bukkit.entity.Player player)
|
||||
|
@ -15,6 +15,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.stats.command.GiveStatCommand;
|
||||
import mineplex.core.stats.command.MasterBuilderUnban;
|
||||
import mineplex.core.stats.command.TimeCommand;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
|
||||
@ -26,6 +27,8 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
|
||||
private NautHashMap<String, Integer> _stats = new NautHashMap<String, Integer>();
|
||||
private NautHashMap<Player, NautHashMap<String, Long>> _statUploadQueue = new NautHashMap<Player, NautHashMap<String, Long>>();
|
||||
private NautHashMap<Player, NautHashMap<String, Long>> _statUploadQueueOverRidable = new NautHashMap<Player, NautHashMap<String, Long>>();
|
||||
|
||||
private Runnable _saveRunnable;
|
||||
|
||||
public StatsManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
@ -41,6 +44,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
public void run()
|
||||
{
|
||||
saveStats();
|
||||
overRidableSaveStats();
|
||||
}
|
||||
};
|
||||
|
||||
@ -81,6 +85,11 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
}
|
||||
|
||||
public void incrementStat(final Player player, final String statName, final long value)
|
||||
{
|
||||
incrementStat(player, statName, value, false);
|
||||
}
|
||||
|
||||
public void incrementStat(final Player player, final String statName, final long value, boolean overRide)
|
||||
{
|
||||
if (value <= 0)
|
||||
return;
|
||||
@ -96,11 +105,80 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
addToQueue(statName, player, value);
|
||||
if(overRide)
|
||||
{
|
||||
addToOverRidableQueue(statName, player, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
addToQueue(statName, player, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addToOverRidableQueue(String statName, Player player, long value)
|
||||
{
|
||||
synchronized (_statSync)
|
||||
{
|
||||
if (!_statUploadQueueOverRidable.containsKey(player))
|
||||
_statUploadQueueOverRidable.put(player, new NautHashMap<String, Long>());
|
||||
|
||||
if (!_statUploadQueueOverRidable.get(player).containsKey(statName))
|
||||
_statUploadQueueOverRidable.get(player).put(statName, 0L);
|
||||
|
||||
_statUploadQueueOverRidable.get(player).put(statName, _statUploadQueueOverRidable.get(player).get(statName) + value);
|
||||
}
|
||||
}
|
||||
|
||||
protected void overRidableSaveStats()
|
||||
{
|
||||
if (_statUploadQueueOverRidable.isEmpty())
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
|
||||
|
||||
synchronized (_statSync)
|
||||
{
|
||||
for (Iterator<Player> statIterator = _statUploadQueueOverRidable.keySet().iterator(); statIterator.hasNext();)
|
||||
{
|
||||
Player player = statIterator.next();
|
||||
|
||||
if (player.isOnline())
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId();
|
||||
|
||||
uploadQueue.put(uploadKey, new NautHashMap<Integer, Long>());
|
||||
|
||||
for (String statName : _statUploadQueueOverRidable.get(player).keySet())
|
||||
{
|
||||
int statId = _stats.get(statName);
|
||||
uploadQueue.get(uploadKey).put(statId, _statUploadQueueOverRidable.get(player).get(statName));
|
||||
System.out.println(player.getName() + " saving stat : " + statName + " overriding " + _statUploadQueueOverRidable.get(player).get(statName));
|
||||
}
|
||||
|
||||
statIterator.remove();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//System.out.println("[StatsManager] AccountId was not set for " + player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_repository.saveStats(uploadQueue, true);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void addToQueue(String statName, Player player, long value)
|
||||
{
|
||||
synchronized (_statSync)
|
||||
@ -164,6 +242,11 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
}
|
||||
|
||||
public boolean incrementStat(final int accountId, final String statName, final long value)
|
||||
{
|
||||
return incrementStat(accountId, statName, value, false);
|
||||
}
|
||||
|
||||
public boolean incrementStat(final int accountId, final String statName, final long value, boolean overRide)
|
||||
{
|
||||
// This will register a new stat if we don't have one, otherwise it will just run the callback
|
||||
registerNewStat(statName, new Runnable()
|
||||
@ -175,7 +258,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
|
||||
uploadQueue.get(accountId).put(_stats.get(statName), value);
|
||||
|
||||
_repository.saveStats(uploadQueue);
|
||||
_repository.saveStats(uploadQueue, overRide);
|
||||
}
|
||||
});
|
||||
|
||||
@ -237,6 +320,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
{
|
||||
addCommand(new TimeCommand(this));
|
||||
addCommand(new GiveStatCommand(this));
|
||||
addCommand(new MasterBuilderUnban(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,16 +6,14 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.database.Tables;
|
||||
import net.md_5.bungee.chat.TranslatableComponentSerializer;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Insert;
|
||||
import org.jooq.Record2;
|
||||
@ -30,6 +28,7 @@ public class StatsRepository extends RepositoryBase
|
||||
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
|
||||
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
||||
|
||||
|
||||
public StatsRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
@ -69,8 +68,14 @@ public class StatsRepository extends RepositoryBase
|
||||
executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void saveStats(NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue)
|
||||
{
|
||||
saveStats(uploadQueue, false);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void saveStats(NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue, boolean overRideStat)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -83,13 +88,24 @@ public class StatsRepository extends RepositoryBase
|
||||
{
|
||||
for (Integer statId : uploadQueue.get(accountId).keySet())
|
||||
{
|
||||
Update update = context
|
||||
if(overRideStat)
|
||||
{
|
||||
Update update = context
|
||||
.update(Tables.accountStat)
|
||||
.set(Tables.accountStat.value, ULong.valueOf(uploadQueue.get(accountId).get(statId)))
|
||||
.where(Tables.accountStat.accountId.eq(accountId))
|
||||
.and(Tables.accountStat.statId.eq(statId));
|
||||
updates.add(update);
|
||||
}
|
||||
else
|
||||
{
|
||||
Update update = context
|
||||
.update(Tables.accountStat)
|
||||
.set(Tables.accountStat.value, Tables.accountStat.value.plus(uploadQueue.get(accountId).get(statId)))
|
||||
.where(Tables.accountStat.accountId.eq(accountId))
|
||||
.and(Tables.accountStat.statId.eq(statId));
|
||||
|
||||
updates.add(update);
|
||||
updates.add(update);
|
||||
}
|
||||
|
||||
Insert insert = context
|
||||
.insertInto(Tables.accountStat)
|
||||
|
@ -0,0 +1,104 @@
|
||||
package mineplex.core.stats.command;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MasterBuilderUnban extends CommandBase<StatsManager>
|
||||
{
|
||||
|
||||
public MasterBuilderUnban(StatsManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "buildunban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if(args.length != 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("MasterBuilder Unban", "/buildunban <Target>"));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Plugin.getClientManager().getRepository().matchPlayerName(new Callback<List<String>>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run(List<String> matches)
|
||||
{
|
||||
boolean matchedExact = false;
|
||||
|
||||
for (String match : matches)
|
||||
{
|
||||
if (match.equalsIgnoreCase(args[0]))
|
||||
{
|
||||
matchedExact = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedExact)
|
||||
{
|
||||
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
|
||||
{
|
||||
if (!matchIterator.next().equalsIgnoreCase(args[0]))
|
||||
{
|
||||
matchIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
UtilPlayer.searchOffline(matches, new Callback<String>()
|
||||
{
|
||||
@Override
|
||||
public void run(String target)
|
||||
{
|
||||
if(target == null)
|
||||
{
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!"));
|
||||
return;
|
||||
}
|
||||
Plugin.getClientManager().loadClientByName(target, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
CoreClient theClient = Plugin.getClientManager().Get(target);
|
||||
|
||||
if(theClient != null)
|
||||
{
|
||||
Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders"));
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, caller, args[0], false);
|
||||
}
|
||||
|
||||
}, args[0]);
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened."));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -8,13 +8,13 @@ import mineplex.core.reward.RewardType;
|
||||
|
||||
public enum TreasureType
|
||||
{
|
||||
OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL),
|
||||
OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL, true, 1000),
|
||||
|
||||
ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL),
|
||||
ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL, true, 5000),
|
||||
|
||||
MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL),
|
||||
MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL, true, 10000),
|
||||
|
||||
CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY);
|
||||
CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY, false, 15000);
|
||||
|
||||
private final String _name;
|
||||
private final RewardType _rewardType;
|
||||
@ -23,8 +23,10 @@ public enum TreasureType
|
||||
private final String _itemName;
|
||||
private final String _statName;
|
||||
private final RewardPool.Type _rewardPool;
|
||||
private final int _purchasePrice;
|
||||
private final boolean _purchasable;
|
||||
|
||||
TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool)
|
||||
TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool, boolean purchasable, int purchasePrice)
|
||||
{
|
||||
_name = name;
|
||||
_itemName = itemName;
|
||||
@ -33,6 +35,8 @@ public enum TreasureType
|
||||
_material = material;
|
||||
_treasureStyle = treasureStyle;
|
||||
_rewardPool = rewardPool;
|
||||
_purchasePrice = purchasePrice;
|
||||
_purchasable = purchasable;
|
||||
}
|
||||
|
||||
public RewardType getRewardType()
|
||||
@ -69,4 +73,14 @@ public enum TreasureType
|
||||
{
|
||||
return _rewardPool;
|
||||
}
|
||||
|
||||
public int getPurchasePrice()
|
||||
{
|
||||
return _purchasePrice;
|
||||
}
|
||||
|
||||
public boolean isPurchasable()
|
||||
{
|
||||
return _purchasable;
|
||||
}
|
||||
}
|
||||
|
@ -122,9 +122,11 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
|
||||
christmasLore.add(ChatColor.RESET + C.cGreen + "Click to Open!");
|
||||
else
|
||||
{
|
||||
/*
|
||||
christmasLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "15000 Treasure Shards");
|
||||
christmasLore.add(" ");
|
||||
christmasLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
|
||||
*/
|
||||
}
|
||||
|
||||
List<String> cosmicLore = new ArrayList<String>();
|
||||
@ -143,18 +145,21 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
|
||||
|
||||
addItem(40, shards);
|
||||
|
||||
if (basicCount > 0) addButton(20, basic, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.OLD));
|
||||
else addButton(20, basic, new BuyChestButton(getPlayer(), _inventoryManager, this, "Old Chest", Material.CHEST, 1000));
|
||||
|
||||
if (heroicCount > 0) addButton(22, heroic, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.ANCIENT));
|
||||
else addButton(22, heroic, new BuyChestButton(getPlayer(), _inventoryManager, this, "Ancient Chest", Material.CHEST, 5000));
|
||||
|
||||
if (legendaryCount > 0) addButton(24, legendary, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.MYTHICAL));
|
||||
else addButton(24, legendary, new BuyChestButton(getPlayer(), _inventoryManager, this, "Mythical Chest", Material.ENDER_CHEST, 10000));
|
||||
|
||||
if (christmasCount > 0) addButton(12, christmas, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.CHRISTMAS));
|
||||
else addButton(12, christmas, new BuyChestButton(getPlayer(), _inventoryManager, this, TreasureType.CHRISTMAS.getItemName(), Material.SNOW_BALL, 15000));
|
||||
addChest(20, basic, TreasureType.OLD, basicCount);
|
||||
addChest(22, heroic, TreasureType.ANCIENT, heroicCount);
|
||||
addChest(24, legendary, TreasureType.MYTHICAL, legendaryCount);
|
||||
addChest(12, christmas, TreasureType.CHRISTMAS, christmasCount);
|
||||
|
||||
addItem(14, cosmic);
|
||||
}
|
||||
|
||||
private void addChest(int slot, ItemStack item, TreasureType treasureType, int owned)
|
||||
{
|
||||
if (owned > 0)
|
||||
addButton(slot, item, new OpenTreasureButton(getPlayer(), _treasureLocation, treasureType));
|
||||
else if (treasureType.isPurchasable())
|
||||
addButton(slot, item, new BuyChestButton(getPlayer(), _inventoryManager, this, treasureType.getItemName(), Material.CHEST, treasureType.getPurchasePrice()));
|
||||
else
|
||||
setItem(slot, item);
|
||||
}
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor
|
||||
{
|
||||
if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp())
|
||||
{
|
||||
// event.setKickMessage("This is not your Clans home server");
|
||||
// event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
event.setKickMessage("This is not your Clans home server");
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
}
|
||||
|
||||
_queue.remove(event.getPlayer().getName());
|
||||
@ -50,18 +50,18 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor
|
||||
|
||||
private void kickPlayer(final String playerName, final String homeServer)
|
||||
{
|
||||
// runSyncLater(new Runnable()
|
||||
// {
|
||||
// @Override
|
||||
// public void run()
|
||||
// {
|
||||
// Player player = UtilPlayer.searchExact(playerName);
|
||||
// if (player != null && player.isOnline() && !player.isOp())
|
||||
// {
|
||||
// player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer);
|
||||
// }
|
||||
// }
|
||||
// }, 20);
|
||||
runSyncLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(playerName);
|
||||
if (player != null && player.isOnline() && !player.isOp())
|
||||
{
|
||||
player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer);
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,6 +55,7 @@ import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.core.velocity.VelocityFix;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.hub.modules.NewYearCountdown;
|
||||
import mineplex.hub.modules.StackerManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
|
@ -33,6 +33,7 @@ import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.PlayerDisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseSlime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
@ -134,7 +135,7 @@ import org.bukkit.scoreboard.Scoreboard;
|
||||
public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
// ☃❅ Snowman!
|
||||
public HubType Type = HubType.Christmas;
|
||||
public HubType Type = HubType.Normal;
|
||||
|
||||
private BlockRestore _blockRestore;
|
||||
private CoreClientManager _clientManager;
|
||||
@ -248,8 +249,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
|
||||
// _halloweenManager = new HalloweenSpookinessManager(this);
|
||||
|
||||
new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
|
||||
|
||||
// new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
|
||||
new PlayerDisguiseManager(plugin, _clientManager);
|
||||
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
|
||||
// new MailManager(_plugin, notificationManager);
|
||||
|
||||
@ -295,6 +296,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
|
||||
private void playNextSong()
|
||||
{
|
||||
if (Type != HubType.Christmas)
|
||||
return;
|
||||
|
||||
if (_songs.isEmpty())
|
||||
return;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package mineplex.hub.commands;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.NCPDataManFix;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -14,17 +13,26 @@ import mineplex.core.common.util.ProfileLoader;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.PlayerUndisguiseEvent;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.donation.Donor;
|
||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.HubManager;
|
||||
import net.minecraft.server.v1_8_R3.ChatComponentText;
|
||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.EnumDifficulty;
|
||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn;
|
||||
import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode;
|
||||
import net.minecraft.server.v1_8_R3.WorldType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -38,13 +46,12 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mysql.jdbc.BalanceStrategy;
|
||||
|
||||
public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
{
|
||||
@ -55,11 +62,9 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
|
||||
public DisguiseCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.JNR_DEV, new Rank[]
|
||||
{
|
||||
Rank.YOUTUBE, Rank.TWITCH }, "disguise");
|
||||
super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise");
|
||||
|
||||
plugin.getPluginManager().registerEvents(this, Plugin.getPlugin());
|
||||
new NCPDataManFix();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,36 +74,57 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
{
|
||||
if(!Plugin.GetDisguise().isDisguised(caller))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise <name> first");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "please use /disguise <name> first"));
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
GameProfile profile = _disguisedPlayers.get(caller);
|
||||
_disguisedPlayers.remove(caller);
|
||||
_disguisedPlayerDisguises.remove(caller);
|
||||
Plugin.GetDisguise().undisguise(caller);
|
||||
String playerName = _disguisedPlayersNames.get(caller);
|
||||
Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller));
|
||||
|
||||
CoreClient client = Plugin.GetClients().Get(caller);
|
||||
client.setDisguisedRank(null);
|
||||
client.setDisguisedAs(null);
|
||||
client.setDisguised(false);
|
||||
|
||||
changeName(caller, playerName);
|
||||
changeName(caller, playerName, true);
|
||||
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false);
|
||||
|
||||
Field field;
|
||||
try
|
||||
{
|
||||
field = GameProfile.class.getDeclaredField("id");
|
||||
field.setAccessible(true);
|
||||
UUID old = ((CraftPlayer) caller).getProfile().getId();
|
||||
UUID newUUID = profile.getId();
|
||||
field.set(profile, old);
|
||||
field.set(((CraftPlayer) caller).getProfile(), newUUID);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// removed "due to Kicked for Flying"
|
||||
//PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue()));
|
||||
//UtilPlayer.sendPacket(caller, packet);
|
||||
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
for(Team team : other.getScoreboard().getTeams())
|
||||
{
|
||||
if(team.hasPlayer(caller))
|
||||
{
|
||||
team.removePlayer(caller);
|
||||
}
|
||||
team.removePlayer(caller);
|
||||
}
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!"));
|
||||
return;
|
||||
} catch(Exception ex)
|
||||
{
|
||||
@ -107,12 +133,10 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
}
|
||||
if(args != null && args.length > 1)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise <name>");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "/disguise <name>"));
|
||||
return;
|
||||
}
|
||||
|
||||
final Rank rank = Plugin.GetClients().Get(caller).GetRank();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -120,40 +144,41 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
{
|
||||
if(Plugin.GetDisguise().isDisguised(caller))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first"));
|
||||
return;
|
||||
}
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if(other.getName().equalsIgnoreCase(args[0]))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!");
|
||||
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(_disguisedPlayersNames.containsValue(args[0]))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!");
|
||||
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!"));
|
||||
return;
|
||||
}
|
||||
if(args[0].length() > 16)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
|
||||
UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0]));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CoreClient client = Plugin.GetClients().Get(caller);
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(args[0]);
|
||||
UUID uuid = UUID.randomUUID();
|
||||
GameProfile profile = null;
|
||||
try
|
||||
{
|
||||
uuid = UUIDFetcher.getUUIDOf(args[0]);
|
||||
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
||||
} catch(Exception e)
|
||||
} catch (Exception e)
|
||||
{
|
||||
uuid = UUIDFetcher.getUUIDOf("Alex");
|
||||
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
||||
uuid = UUID.randomUUID();
|
||||
profile = new ProfileLoader(null, args[0]).loadProfile();
|
||||
}
|
||||
|
||||
Rank otherRank = Rank.ALL;
|
||||
@ -164,9 +189,9 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
otherRank = other.GetRank();
|
||||
} catch(NullPointerException exception)
|
||||
{}
|
||||
if(otherRank.has(Rank.TWITCH) && !rank.has(Rank.OWNER))
|
||||
if(otherRank.has(Rank.TWITCH))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!"));
|
||||
return;
|
||||
}
|
||||
_disguisedPlayers.put(caller, profile);
|
||||
@ -176,21 +201,100 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
|
||||
client.setDisguisedAs(args[0]);
|
||||
|
||||
changeName(caller, args[0]);
|
||||
changeName(caller, args[0], true);
|
||||
|
||||
Plugin.GetGadget().removeGadgetType(caller, GadgetType.Item);
|
||||
|
||||
UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]);
|
||||
// Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller));
|
||||
UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0]));
|
||||
|
||||
Field field;
|
||||
try
|
||||
{
|
||||
field = GameProfile.class.getDeclaredField("id");
|
||||
field.setAccessible(true);
|
||||
UUID old = ((CraftPlayer) caller).getProfile().getId();
|
||||
UUID newUUID = profile.getId();
|
||||
field.set(profile, old);
|
||||
field.set(((CraftPlayer) caller).getProfile(), newUUID);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue()));
|
||||
UtilPlayer.sendPacket(caller, packet);
|
||||
|
||||
tablistRefresh(caller);
|
||||
} catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
|
||||
UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void refreshTabNames(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
for(Player player : _disguisedPlayers.keySet())
|
||||
{
|
||||
if(!player.isOnline())
|
||||
return;
|
||||
|
||||
tablistRefresh(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void tablistRefresh(Player player)
|
||||
{
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if (player.canSee(other))
|
||||
{
|
||||
updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly)
|
||||
{
|
||||
ChatColor team = ChatColor.WHITE;
|
||||
Player player = Bukkit.getPlayer(profileToAdd.getName());
|
||||
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||
String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " ";
|
||||
if(Plugin.GetClients().Get(player).isDisguised())
|
||||
{
|
||||
tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " ";
|
||||
}
|
||||
|
||||
IChatBaseComponent component = new ChatComponentText(tag + team + player.getName());
|
||||
|
||||
if(!refreshOnly)
|
||||
{
|
||||
PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER);
|
||||
PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||
removePacket.b.add(removeData);
|
||||
UtilPlayer.sendPacket(target, removePacket);
|
||||
|
||||
PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER);
|
||||
PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||
addPacket.b.add(addData);
|
||||
UtilPlayer.sendPacket(target, addPacket);
|
||||
}
|
||||
|
||||
PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME);
|
||||
PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||
updatePacket.b.add(updateData);
|
||||
UtilPlayer.sendPacket(target, updatePacket);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateDisguises(UpdateEvent event)
|
||||
{
|
||||
@ -206,15 +310,11 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
{
|
||||
try
|
||||
{
|
||||
for(Team team : other.getScoreboard().getTeams())
|
||||
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player))
|
||||
{
|
||||
if(team.hasPlayer(player))
|
||||
{
|
||||
team.removePlayer(player);
|
||||
}
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player);
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player);
|
||||
}
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player);
|
||||
|
||||
} catch(NullPointerException exp)
|
||||
{}
|
||||
}
|
||||
@ -228,18 +328,17 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
public void changeName(Player player, String changedName)
|
||||
public void changeName(final Player player, String changedName, boolean skin)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field name = GameProfile.class.getDeclaredField("name");
|
||||
Field declaredProfile = EntityHuman.class.getDeclaredField("bH");
|
||||
declaredProfile.setAccessible(true);
|
||||
GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle());
|
||||
GameProfile gameProfile = ((CraftPlayer) player).getProfile();
|
||||
|
||||
Field name = GameProfile.class.getDeclaredField("name");
|
||||
name.setAccessible(true);
|
||||
name.set(gameProfile, changedName);
|
||||
name.setAccessible(false);
|
||||
|
||||
} catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
@ -266,7 +365,7 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
client.setDisguisedAs(null);
|
||||
client.setDisguised(false);
|
||||
|
||||
changeName(player, playerName);
|
||||
changeName(player, playerName, true);
|
||||
} catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
@ -321,6 +420,21 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeftClick(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
if(_disguisedPlayers.containsKey(player))
|
||||
{
|
||||
EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle());
|
||||
human.world.broadcastEntityEffect(human, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onDPlayerChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
@ -353,5 +467,4 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.hub.modules.NewYearCountdown;
|
||||
import mineplex.hub.modules.newyear.NewYearMessage;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 29/12/15
|
||||
*/
|
||||
public class NewYearCommand extends CommandBase<NewYearCountdown>
|
||||
{
|
||||
public NewYearCommand(NewYearCountdown plugin)
|
||||
{
|
||||
super(plugin, Rank.JNR_DEV, "newyear", "nycountdown", "nyc");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (Plugin.isInProgress())
|
||||
{
|
||||
caller.sendMessage(F.main("NYC", C.cRed + "A new year countdown event is already in progress!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length != 3)
|
||||
{
|
||||
caller.sendMessage(F.main("NYC", C.cRed + "/newyear <hours> <minutes> <seconds>"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(validateInteger(args[0]) && validateInteger(args[1]) && validateInteger(args[2])))
|
||||
{
|
||||
caller.sendMessage(F.main("NYC", C.cRed + "You have entered invalid hours/minutes/seconds."));
|
||||
return;
|
||||
}
|
||||
|
||||
int hours = Integer.valueOf(args[0]);
|
||||
int mins = Integer.valueOf(args[1]);
|
||||
int secs = Integer.valueOf(args[2]);
|
||||
int total = secs + (mins * 60) + (hours * 60 * 60);
|
||||
|
||||
caller.sendMessage(F.main("NYC", "Sent command to all lobbies to start with " + F.elem(total + "") + " seconds."));
|
||||
new NewYearMessage(total).publish();
|
||||
}
|
||||
|
||||
private boolean validateInteger(String str)
|
||||
{
|
||||
boolean passed = false;
|
||||
try
|
||||
{
|
||||
int i = Integer.valueOf(str);
|
||||
passed = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH))
|
||||
if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL))
|
||||
{
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
|
@ -70,13 +70,14 @@ public class HubVisibilityManager extends MiniPlugin
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
boolean localHideMe = hideMe;
|
||||
if (player.equals(other))
|
||||
continue;
|
||||
|
||||
if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR))
|
||||
hideMe = false;
|
||||
localHideMe = false;
|
||||
|
||||
if (hideMe ||
|
||||
if (localHideMe ||
|
||||
!Manager.getPreferences().Get(other).ShowPlayers ||
|
||||
Manager.GetTutorial().InTutorial(other))
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
@ -83,7 +84,8 @@ public class JumpManager extends MiniPlugin
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
continue;
|
||||
|
||||
if (Manager.getPreferences().Get(player).Invisibility)
|
||||
Rank rank = Manager.GetClients().Get(player).GetRank();
|
||||
if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH))
|
||||
{
|
||||
player.setAllowFlight(true);
|
||||
continue;
|
||||
|
@ -0,0 +1,283 @@
|
||||
package mineplex.hub.modules;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.commands.NewYearCommand;
|
||||
import mineplex.hub.modules.newyear.NewYearHandler;
|
||||
import mineplex.hub.modules.newyear.NewYearMessage;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 29/12/15
|
||||
*/
|
||||
public class NewYearCountdown extends MiniPlugin
|
||||
{
|
||||
private boolean _inProgress;
|
||||
private Location _center;
|
||||
private Location _spawn;
|
||||
private int _stage;
|
||||
private long _targetTime;
|
||||
private BufferedImage _currentFrame;
|
||||
|
||||
public NewYearCountdown(JavaPlugin plugin)
|
||||
{
|
||||
super("New Year Countdown", plugin);
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("NewYearMessage",
|
||||
NewYearMessage.class, new NewYearHandler(this));
|
||||
|
||||
_center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5);
|
||||
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5);
|
||||
_inProgress = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
CommandCenter.Instance.AddCommand(new NewYearCommand(this));
|
||||
}
|
||||
|
||||
public boolean isInProgress()
|
||||
{
|
||||
return _inProgress;
|
||||
}
|
||||
|
||||
public void start(int seconds)
|
||||
{
|
||||
_inProgress = true;
|
||||
_stage = seconds;
|
||||
UtilWorld.getWorld("world").setTime(18000);
|
||||
_currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage));
|
||||
_targetTime = System.currentTimeMillis() + (seconds * 1000);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateStage(UpdateEvent e)
|
||||
{
|
||||
if (e.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (!_inProgress)
|
||||
return;
|
||||
|
||||
int stageAttempt = (int) ((_targetTime - System.currentTimeMillis()) / 1000);
|
||||
|
||||
if (stageAttempt != _stage)
|
||||
{
|
||||
_stage = stageAttempt;
|
||||
|
||||
if (_stage > 0 && _stage <= 10)
|
||||
for (Player p : UtilServer.getPlayers())
|
||||
p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f);
|
||||
|
||||
if (_stage <= 0)
|
||||
return;
|
||||
|
||||
UtilTextBottom.display(C.cWhiteB + "New Year's Countdown - " + C.cGoldB + formatTimer(_stage), UtilServer.getPlayers());
|
||||
|
||||
_currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent e)
|
||||
{
|
||||
if (e.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
if (!_inProgress)
|
||||
return;
|
||||
|
||||
if (_stage == 0)
|
||||
{
|
||||
_currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 20), "Happy New Year");
|
||||
UtilTextMiddle.display(C.cGoldB + "2016", C.cYellowB + "Happy New Year!", UtilServer.getPlayers());
|
||||
//fireworkCircle();
|
||||
}
|
||||
|
||||
if (_stage <= -120)
|
||||
{
|
||||
//End of event.
|
||||
_inProgress = false;
|
||||
_currentFrame = null;
|
||||
UtilWorld.getWorld("world").setTime(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stage <= 0)
|
||||
{
|
||||
randomFirework(offsetLoc(_center));
|
||||
randomFirework(offsetLoc(_center));
|
||||
randomFirework(offsetLoc(_center));
|
||||
}
|
||||
|
||||
new BukkitRunnable(){
|
||||
ArrayList<Location> line = UtilShapes.getLinesDistancedPoints(offsetLoc(_center), offsetLoc(_center), 0.2);
|
||||
UtilParticle.ParticleType type = getRandomParticle();
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
UtilParticle.PlayParticle(type, line.get(0), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX);
|
||||
line.remove(0);
|
||||
|
||||
if (line.isEmpty())
|
||||
this.cancel();
|
||||
}
|
||||
}.runTaskTimer(getPlugin(), 0L, 1L);
|
||||
|
||||
if (_currentFrame == null)
|
||||
return;
|
||||
|
||||
for (int y = 0; y < _currentFrame.getHeight(); y++)
|
||||
for (int x = 0; x < _currentFrame.getWidth(); x++)
|
||||
{
|
||||
if (java.awt.Color.black.getRGB() != _currentFrame.getRGB(x, y))
|
||||
continue;
|
||||
|
||||
Vector v = new Vector((float) _currentFrame.getWidth() / 2 - x, (float) _currentFrame.getHeight() / 2 - y, 0).multiply(0.5);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX);
|
||||
_center.subtract(v);
|
||||
}
|
||||
}
|
||||
|
||||
private BufferedImage stringToBufferedImage(Font font, String s)
|
||||
{
|
||||
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g = img.getGraphics();
|
||||
g.setFont(font);
|
||||
|
||||
FontRenderContext frc = g.getFontMetrics().getFontRenderContext();
|
||||
Rectangle2D rect = font.getStringBounds(s, frc);
|
||||
g.dispose();
|
||||
|
||||
img = new BufferedImage((int) Math.ceil(rect.getWidth()), (int) Math.ceil(rect.getHeight()), BufferedImage.TYPE_4BYTE_ABGR);
|
||||
g = img.getGraphics();
|
||||
g.setColor(java.awt.Color.black);
|
||||
g.setFont(font);
|
||||
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
int x = 0;
|
||||
int y = fm.getAscent();
|
||||
|
||||
g.drawString(s, x, y);
|
||||
g.dispose();
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
private String formatTimer(long seconds)
|
||||
{
|
||||
long minutes = seconds / 60;
|
||||
long hours = minutes / 60;
|
||||
|
||||
if ((hours % 60) > 0)
|
||||
return zeroNumber(hours % 60) + ":" + zeroNumber(minutes % 60) + ":" + zeroNumber(seconds % 60);
|
||||
|
||||
if ((minutes % 60) > 0)
|
||||
return zeroNumber(minutes % 60) + ":" + zeroNumber(seconds % 60);
|
||||
|
||||
return zeroNumber(seconds % 60);
|
||||
}
|
||||
|
||||
private String zeroNumber(long time)
|
||||
{
|
||||
return (time < 10 ? "0" : "") + time;
|
||||
}
|
||||
|
||||
private Location offsetLoc(Location loc)
|
||||
{
|
||||
Random random = new Random();
|
||||
return loc.clone().add((random.nextInt(100) - 50) + random.nextDouble() - 0.5, random.nextInt(20) + random.nextDouble() - 0.5, (random.nextInt(100) - 50) + random.nextDouble() - 0.5);
|
||||
}
|
||||
|
||||
public static void randomFirework(Location l)
|
||||
{
|
||||
Color c = Color.RED;
|
||||
int r = new Random().nextInt(4);
|
||||
if (r == 0)
|
||||
{
|
||||
c = Color.AQUA;
|
||||
}
|
||||
else if (r == 1)
|
||||
{
|
||||
c = Color.YELLOW;
|
||||
}
|
||||
else if (r == 2)
|
||||
{
|
||||
c = Color.RED;
|
||||
} else if (r == 3)
|
||||
{
|
||||
c = Color.LIME;
|
||||
}
|
||||
FireworkEffect.Type t = FireworkEffect.Type.BALL;
|
||||
int rType = new Random().nextInt(4);
|
||||
if (rType == 0)
|
||||
{
|
||||
t = FireworkEffect.Type.BALL_LARGE;
|
||||
}
|
||||
else if (rType == 1)
|
||||
{
|
||||
t = FireworkEffect.Type.BURST;
|
||||
}
|
||||
else if (rType == 2)
|
||||
{
|
||||
t = FireworkEffect.Type.STAR;
|
||||
}
|
||||
else if (rType == 3)
|
||||
{
|
||||
t = FireworkEffect.Type.CREEPER;
|
||||
}
|
||||
Firework f = l.getWorld().spawn(l, Firework.class);
|
||||
FireworkMeta fm = f.getFireworkMeta();
|
||||
fm.addEffect(FireworkEffect.builder().with(t).withColor(c).build());
|
||||
fm.setPower(0 + new Random().nextInt(2));
|
||||
f.setFireworkMeta(fm);
|
||||
}
|
||||
|
||||
private void fireworkCircle()
|
||||
{
|
||||
for (Location cur : UtilShapes.getPointsInCircle(_spawn, 35, 30))
|
||||
{
|
||||
UtilFirework.launchFirework(cur, FireworkEffect.Type.BALL, Color.FUCHSIA, false, true, cur.toVector().setY(3).multiply(1), 2);
|
||||
}
|
||||
}
|
||||
|
||||
public UtilParticle.ParticleType getRandomParticle()
|
||||
{
|
||||
List<UtilParticle.ParticleType> types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST, UtilParticle.ParticleType.FIREWORKS_SPARK);
|
||||
return types.get(new Random().nextInt(types.size()));
|
||||
}
|
||||
|
||||
}
|
@ -262,34 +262,33 @@ public class NewsManager extends MiniPlugin
|
||||
{
|
||||
_animationIndex = (_animationIndex + 1) % 40;
|
||||
|
||||
if (_animationIndex == 0) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 5" + C.cWhiteB + "0% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 1) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50" + C.cWhiteB + "% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 2) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% " + C.cWhiteB + "OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 3) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% O" + C.cWhiteB + "FF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 4) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OF" + C.cWhiteB + "F ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 5) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF " + C.cWhiteB + "ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 6) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF A" + C.cWhiteB + "LL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 7) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF AL" + C.cWhiteB + "L RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 8) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL " + C.cWhiteB + "RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 9) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL R" + C.cWhiteB + "ANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 10) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RA" + C.cWhiteB + "NKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RAN" + C.cWhiteB + "KS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 12) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANK" + C.cWhiteB + "S " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 13) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 2) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " U" + C.cWhiteB + "P TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 3) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP" + C.cWhiteB + " TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 4) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP " + C.cWhiteB + "TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 5) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP T" + C.cWhiteB + "O 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 6) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO" + C.cWhiteB + " 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 7) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO " + C.cWhiteB + "50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 8) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 5" + C.cWhiteB + "0% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 9) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50" + C.cWhiteB + "% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 10) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50%" + C.cWhiteB + " OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% " + C.cWhiteB + "OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% O" + C.cWhiteB + "FF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 12) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OF" + C.cWhiteB + "F " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 13) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
|
||||
if (_animationIndex == 14) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 15) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 16) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 17) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 18) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 19) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 20) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 21) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 22) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 23) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 24) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 25) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 26) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 14) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 15) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 16) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 17) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 18) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 19) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 20) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 21) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 22) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 23) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 24) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 25) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
if (_animationIndex == 26) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
|
||||
if (_animationIndex >= 27)
|
||||
text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " " + C.cWhiteB + "50% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄";
|
||||
|
@ -0,0 +1,28 @@
|
||||
package mineplex.hub.modules.newyear;
|
||||
|
||||
import mineplex.hub.modules.NewYearCountdown;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 31/12/15
|
||||
*/
|
||||
public class NewYearHandler implements CommandCallback
|
||||
{
|
||||
private NewYearCountdown _newYear;
|
||||
|
||||
public NewYearHandler(NewYearCountdown newYear)
|
||||
{
|
||||
_newYear = newYear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
{
|
||||
if (command instanceof NewYearMessage)
|
||||
{
|
||||
_newYear.start(((NewYearMessage)command).getSeconds());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package mineplex.hub.modules.newyear;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 31/12/15
|
||||
*/
|
||||
public class NewYearMessage extends ServerCommand
|
||||
{
|
||||
|
||||
private int seconds;
|
||||
|
||||
public NewYearMessage(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return seconds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -86,7 +86,7 @@ public class ServerManager extends MiniPlugin
|
||||
private NautHashMap<String, ServerNpcShop> _serverNpcShopMap = new NautHashMap<String, ServerNpcShop>();
|
||||
private NautHashMap<String, ServerInfo> _serverInfoMap = new NautHashMap<String, ServerInfo>();
|
||||
private NautHashMap<String, Long> _serverUpdate = new NautHashMap<String, Long>();
|
||||
private NautHashMap<Vector, String> _serverPortalLocations = new NautHashMap<Vector, String>();
|
||||
private NautHashMap<Vector, String> _portalToServerKey = new NautHashMap<Vector, String>();
|
||||
|
||||
private ClansServerShop _clansShop;
|
||||
|
||||
@ -185,14 +185,15 @@ public class ServerManager extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector());
|
||||
String serverKey = _portalToServerKey.get(player.getLocation().getBlock().getLocation().toVector());
|
||||
|
||||
if (serverName != null)
|
||||
if (serverKey != null)
|
||||
{
|
||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>();
|
||||
|
||||
if (hasServerNpc(serverName))
|
||||
serverList.addAll(getServerList(serverName));
|
||||
Collection<ServerInfo> servers = getServerList(serverKey);
|
||||
if (servers != null && servers.size() > 0)
|
||||
serverList.addAll(servers);
|
||||
|
||||
int slots = 1;
|
||||
|
||||
@ -347,9 +348,9 @@ public class ServerManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<ServerInfo> getServerList(String serverNpcName)
|
||||
public Collection<ServerInfo> getServerList(String serverKey)
|
||||
{
|
||||
return _serverKeyInfoMap.get(serverNpcName);
|
||||
return _serverKeyInfoMap.get(serverKey);
|
||||
}
|
||||
|
||||
public Set<String> getAllServers()
|
||||
@ -362,11 +363,6 @@ public class ServerManager extends MiniPlugin
|
||||
return _serverInfoMap.get(serverName);
|
||||
}
|
||||
|
||||
public boolean hasServerNpc(String serverNpcName)
|
||||
{
|
||||
return _serverKeyInfoMap.containsKey(serverNpcName);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updatePages(UpdateEvent event)
|
||||
{
|
||||
@ -711,7 +707,7 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ()))
|
||||
{
|
||||
_serverPortalLocations.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getServerNpcName());
|
||||
_portalToServerKey.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getPrefix());
|
||||
|
||||
if (bottomVector.getBlockX() != topVector.getBlockX())
|
||||
{
|
||||
@ -725,7 +721,7 @@ public class ServerManager extends MiniPlugin
|
||||
blocks++;
|
||||
}
|
||||
|
||||
_serverPortalLocations.put(bottomVector, serverGroup.getServerNpcName());
|
||||
_portalToServerKey.put(bottomVector, serverGroup.getPrefix());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
|
||||
_region = region;
|
||||
_elementType = elementType;
|
||||
_elementLabel = elementLabel;
|
||||
|
||||
}
|
||||
|
||||
public RedisDataRepository(ConnectionData conn, Region region, Class<T> elementType, String elementLabel)
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@ -51,6 +52,7 @@ import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.PlayerDisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.energy.Energy;
|
||||
@ -289,8 +291,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_hologramManager = hologramManager;
|
||||
_idleManager = new IdleManager(this);
|
||||
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
|
||||
new HolidayManager(this, titanGiveaway);
|
||||
// new HolidayManager(this, titanGiveaway);
|
||||
new GameTestingManager(this);
|
||||
new PlayerDisguiseManager(plugin, _clientManager);
|
||||
|
||||
// Game Addons
|
||||
new CompassAddon(plugin, this);
|
||||
|
@ -3,7 +3,6 @@ package nautilus.game.arcade.command;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.NCPDataManFix;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -14,6 +13,7 @@ import mineplex.core.common.util.ProfileLoader;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.PlayerUndisguiseEvent;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
@ -21,8 +21,19 @@ import mineplex.core.treasure.event.TreasureStartEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import net.minecraft.server.v1_8_R3.ChatComponentText;
|
||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.EnumDifficulty;
|
||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn;
|
||||
import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode;
|
||||
import net.minecraft.server.v1_8_R3.WorldType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -52,10 +63,9 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
|
||||
public DisguiseCommand(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, Rank.JNR_DEV, new Rank[]
|
||||
{ Rank.YOUTUBE, Rank.TWITCH }, "disguise");
|
||||
super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.YOUTUBE_SMALL}, "disguise");
|
||||
|
||||
plugin.getPluginManager().registerEvents(this, Plugin.getPlugin());
|
||||
new NCPDataManFix();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,15 +75,17 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
{
|
||||
if(!Plugin.GetDisguise().isDisguised(caller))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise <name> first");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "please use /disguise <name> first"));
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
GameProfile profile = _disguisedPlayers.get(caller);
|
||||
_disguisedPlayers.remove(caller);
|
||||
_disguisedPlayerDisguises.remove(caller);
|
||||
Plugin.GetDisguise().undisguise(caller);
|
||||
String playerName = _disguisedPlayersNames.get(caller);
|
||||
Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller));
|
||||
|
||||
CoreClient client = Plugin.GetClients().Get(caller);
|
||||
client.setDisguisedRank(null);
|
||||
@ -82,6 +94,29 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
|
||||
changeName(caller, playerName, true);
|
||||
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false);
|
||||
|
||||
Field field;
|
||||
try
|
||||
{
|
||||
field = GameProfile.class.getDeclaredField("id");
|
||||
field.setAccessible(true);
|
||||
UUID old = ((CraftPlayer) caller).getProfile().getId();
|
||||
UUID newUUID = profile.getId();
|
||||
field.set(profile, old);
|
||||
field.set(((CraftPlayer) caller).getProfile(), newUUID);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// removed "due to Kicked for Flying"
|
||||
//PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue()));
|
||||
//UtilPlayer.sendPacket(caller, packet);
|
||||
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
for(Team team : other.getScoreboard().getTeams())
|
||||
@ -91,7 +126,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!"));
|
||||
return;
|
||||
} catch(Exception ex)
|
||||
{
|
||||
@ -100,7 +135,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
}
|
||||
if(args != null && args.length > 1)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise <name>");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "/disguise <name>"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -111,40 +146,41 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
{
|
||||
if(Plugin.GetDisguise().isDisguised(caller))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first"));
|
||||
return;
|
||||
}
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if(other.getName().equalsIgnoreCase(args[0]))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!");
|
||||
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(_disguisedPlayersNames.containsValue(args[0]))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!");
|
||||
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!"));
|
||||
return;
|
||||
}
|
||||
if(args[0].length() > 16)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
|
||||
UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0]));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CoreClient client = Plugin.GetClients().Get(caller);
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(args[0]);
|
||||
UUID uuid = UUID.randomUUID();
|
||||
GameProfile profile = null;
|
||||
try
|
||||
{
|
||||
uuid = UUIDFetcher.getUUIDOf(args[0]);
|
||||
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
||||
} catch(Exception e)
|
||||
} catch (Exception e)
|
||||
{
|
||||
uuid = UUIDFetcher.getUUIDOf("Alex");
|
||||
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
||||
uuid = UUID.randomUUID();
|
||||
profile = new ProfileLoader(null, args[0]).loadProfile();
|
||||
}
|
||||
|
||||
Rank otherRank = Rank.ALL;
|
||||
@ -157,7 +193,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
{}
|
||||
if(otherRank.has(Rank.TWITCH))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!");
|
||||
UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!"));
|
||||
return;
|
||||
}
|
||||
_disguisedPlayers.put(caller, profile);
|
||||
@ -171,18 +207,102 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
|
||||
Plugin.getCosmeticManager().getGadgetManager().removeGadgetType(caller, GadgetType.Item);
|
||||
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller));
|
||||
UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]);
|
||||
// Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller));
|
||||
UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0]));
|
||||
|
||||
Field field;
|
||||
try
|
||||
{
|
||||
field = GameProfile.class.getDeclaredField("id");
|
||||
field.setAccessible(true);
|
||||
UUID old = ((CraftPlayer) caller).getProfile().getId();
|
||||
UUID newUUID = profile.getId();
|
||||
field.set(profile, old);
|
||||
field.set(((CraftPlayer) caller).getProfile(), newUUID);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue()));
|
||||
UtilPlayer.sendPacket(caller, packet);
|
||||
|
||||
tablistRefresh(caller);
|
||||
} catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
|
||||
UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void refreshTabNames(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
for(Player player : _disguisedPlayers.keySet())
|
||||
{
|
||||
if(!player.isOnline())
|
||||
return;
|
||||
|
||||
tablistRefresh(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void tablistRefresh(Player player)
|
||||
{
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if (player.canSee(other))
|
||||
{
|
||||
updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly)
|
||||
{
|
||||
ChatColor team = ChatColor.WHITE;
|
||||
Player player = Bukkit.getPlayer(profileToAdd.getName());
|
||||
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||
if(Plugin.GetGame().GetTeam(player) != null)
|
||||
{
|
||||
team = Plugin.GetGame().GetTeam(player).GetColor();
|
||||
}
|
||||
String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " ";
|
||||
if(Plugin.GetClients().Get(player).isDisguised())
|
||||
{
|
||||
tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " ";
|
||||
}
|
||||
if(Plugin.GetGame().GetState() != GameState.Recruit)
|
||||
tag = "";
|
||||
|
||||
IChatBaseComponent component = new ChatComponentText(tag + team + player.getName());
|
||||
|
||||
if(!refreshOnly)
|
||||
{
|
||||
PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER);
|
||||
PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||
removePacket.b.add(removeData);
|
||||
UtilPlayer.sendPacket(target, removePacket);
|
||||
|
||||
PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER);
|
||||
PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||
addPacket.b.add(addData);
|
||||
UtilPlayer.sendPacket(target, addPacket);
|
||||
}
|
||||
|
||||
PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME);
|
||||
PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||
updatePacket.b.add(updateData);
|
||||
UtilPlayer.sendPacket(target, updatePacket);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateDisguises(UpdateEvent event)
|
||||
{
|
||||
|
@ -119,6 +119,7 @@ public class Build extends SoloGame
|
||||
|
||||
private String[] _words;
|
||||
private String[] _holidayWords;
|
||||
private boolean _useHolidayWords = false;
|
||||
|
||||
private String _word = "?";
|
||||
|
||||
@ -249,7 +250,7 @@ public class Build extends SoloGame
|
||||
player.setFlySpeed(0.1f);
|
||||
}
|
||||
|
||||
if (Math.random() >= 0.5)
|
||||
if (!_useHolidayWords || Math.random() >= 0.5)
|
||||
_word = _words[UtilMath.r(_words.length)];
|
||||
else
|
||||
_word = _holidayWords[UtilMath.r(_holidayWords.length)];
|
||||
|
@ -84,6 +84,7 @@ public class Draw extends SoloGame
|
||||
private HashSet<Tool> _tools;
|
||||
private String[] _words;
|
||||
private String[] _holidayWords;
|
||||
private boolean _useHolidayWords = false;
|
||||
private HashSet<String> _usedWords = new HashSet<String>();
|
||||
|
||||
public Draw(ArcadeManager manager)
|
||||
@ -302,7 +303,7 @@ public class Draw extends SoloGame
|
||||
|
||||
private String getRandomWord()
|
||||
{
|
||||
if (Math.random() >= 0.30)
|
||||
if (!_useHolidayWords || Math.random() >= 0.30)
|
||||
{
|
||||
return _words[UtilMath.r(_words.length)];
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
@ -57,6 +56,8 @@ import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent;
|
||||
import nautilus.game.arcade.game.games.gladiators.events.RoundStartEvent;
|
||||
import nautilus.game.arcade.game.games.gladiators.hotbar.HotbarEditor;
|
||||
import nautilus.game.arcade.game.games.gladiators.hotbar.HotbarLayout;
|
||||
import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator;
|
||||
import nautilus.game.arcade.game.games.gladiators.trackers.BrawlerTracker;
|
||||
import nautilus.game.arcade.game.games.gladiators.trackers.FlawlessTracker;
|
||||
@ -85,6 +86,8 @@ public class Gladiators extends SoloGame
|
||||
|
||||
private boolean _firstRound;
|
||||
|
||||
private HotbarEditor _hotbarEditor;
|
||||
|
||||
public Gladiators(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Gladiators,
|
||||
@ -124,6 +127,8 @@ public class Gladiators extends SoloGame
|
||||
|
||||
_roundState = RoundState.WAITING;
|
||||
_firstRound = true;
|
||||
|
||||
_hotbarEditor = new HotbarEditor(manager.getPlugin(), this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -181,6 +186,9 @@ public class Gladiators extends SoloGame
|
||||
if (e.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (GetState() != GameState.Prepare)
|
||||
return;
|
||||
|
||||
@ -739,13 +747,15 @@ public class Gladiators extends SoloGame
|
||||
if (!GetPlayers(true).contains(p))
|
||||
return;
|
||||
|
||||
HotbarLayout layout = _hotbarEditor.getLayout(p);
|
||||
|
||||
p.getInventory().clear();
|
||||
p.getInventory().setArmorContents(null);
|
||||
|
||||
p.getInventory().setItem(0, UtilItem.makeUnbreakable(type.getLoadout().getSword()));
|
||||
p.getInventory().setItem(1, UtilItem.makeUnbreakable(type.getLoadout().getRod()));
|
||||
p.getInventory().setItem(2, type.getLoadout().getBow());
|
||||
p.getInventory().setItem(8, type.getLoadout().getArrows());
|
||||
p.getInventory().setItem(layout.getSword(), UtilItem.makeUnbreakable(type.getLoadout().getSword()));
|
||||
p.getInventory().setItem(layout.getRod(), UtilItem.makeUnbreakable(type.getLoadout().getRod()));
|
||||
p.getInventory().setItem(layout.getBow(), type.getLoadout().getBow());
|
||||
p.getInventory().setItem(layout.getArrows(), type.getLoadout().getArrows());
|
||||
|
||||
p.getInventory().setHelmet(type.getLoadout().getHelmet());
|
||||
p.getInventory().setChestplate(type.getLoadout().getChestplate());
|
||||
|
@ -0,0 +1,186 @@
|
||||
package nautilus.game.arcade.game.games.gladiators.hotbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.gladiators.Gladiators;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 18/12/15
|
||||
*/
|
||||
public class HotbarEditor extends MiniPlugin
|
||||
{
|
||||
private Gladiators _host;
|
||||
private ItemStack _item;
|
||||
|
||||
public HotbarEditor(JavaPlugin plugin, Gladiators gladiators)
|
||||
{
|
||||
super("Hotbar Editor", plugin);
|
||||
|
||||
_host = gladiators;
|
||||
_item = new ItemBuilder(Material.NAME_TAG).setTitle(C.cGold + "Hotbar Editor")
|
||||
.addLore(C.cGray + "Right click to edit your Gladiators hotbar").build();
|
||||
|
||||
getPluginManager().registerEvents(new HotbarPageListener(this), getPlugin());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_host.Manager.GetGame() != _host)
|
||||
return;
|
||||
|
||||
if (_host.GetState() == Game.GameState.Recruit || _host.GetState() == Game.GameState.Live)
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(0, _item);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(final PlayerDeathEvent event)
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (_host.IsLive())
|
||||
{
|
||||
event.getEntity().getInventory().setItem(0, _item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void Observer(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().equalsIgnoreCase("/spec"))
|
||||
{
|
||||
if (!_host.IsAlive(event.getPlayer())
|
||||
&& !UtilInv.contains(event.getPlayer(), _item.getType(), (byte) 0, 1))
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(0, _item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetGame() != _host)
|
||||
return;
|
||||
|
||||
if (event.GetState() == Game.GameState.Recruit)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
player.getInventory().setItem(0, _item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getAction() != Action.PHYSICAL && event.getAction().name().contains("RIGHT"))
|
||||
{
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
if (item != null && item.isSimilar(_item))
|
||||
{
|
||||
|
||||
HotbarInventory.open(event.getPlayer(), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Gladiators getHost()
|
||||
{
|
||||
return _host;
|
||||
}
|
||||
|
||||
public HotbarLayout getLayout(Player player)
|
||||
{
|
||||
int data = _host.Manager.getArcadePlayer(player).get("hotbar");
|
||||
data = (data == -1 ? 1239 : data);
|
||||
|
||||
List<Integer> ints = new ArrayList<>();
|
||||
for (int i : UtilMath.digits(data))
|
||||
ints.add(i - 1);
|
||||
ints = Lists.reverse(ints);
|
||||
|
||||
return new HotbarLayout(ints.get(0), ints.get(1), ints.get(2), ints.get(3));
|
||||
}
|
||||
|
||||
public void saveLayout(Player player, Inventory inv)
|
||||
{
|
||||
List<ItemStack> items = Arrays.asList(inv.getContents());
|
||||
ItemStack sword = null, rod = null, bow = null, arrows = null;
|
||||
for (ItemStack i : items)
|
||||
{
|
||||
if (i == null || i.getType() == null)
|
||||
continue;
|
||||
|
||||
if (i.getType().equals(Material.DIAMOND_SWORD))
|
||||
sword = i;
|
||||
else if (i.getType().equals(Material.FISHING_ROD))
|
||||
rod = i;
|
||||
else if (i.getType().equals(Material.BOW))
|
||||
bow = i;
|
||||
else if (i.getType().equals(Material.ARROW))
|
||||
arrows = i;
|
||||
}
|
||||
|
||||
HotbarLayout save = new HotbarLayout(
|
||||
items.indexOf(sword) - 9,
|
||||
items.indexOf(rod) - 9,
|
||||
items.indexOf(bow) - 9,
|
||||
items.indexOf(arrows) - 9
|
||||
);
|
||||
|
||||
if (save.getArrows() > 8 || save.getArrows() < 0)
|
||||
{
|
||||
save.setArrows(save.getEmpty());
|
||||
}
|
||||
if (save.getBow() > 8 || save.getBow() < 0)
|
||||
{
|
||||
save.setBow(save.getEmpty());
|
||||
}
|
||||
if (save.getSword() > 8 || save.getSword() < 0)
|
||||
{
|
||||
save.setSword(save.getEmpty());
|
||||
}
|
||||
if (save.getRod() > 8 || save.getRod() < 0)
|
||||
{
|
||||
save.setRod(save.getEmpty());
|
||||
}
|
||||
|
||||
_host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber(), true);
|
||||
player.sendMessage(F.main("Game", "Saved new hotbar layout!"));
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package nautilus.game.arcade.game.games.gladiators.hotbar;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 18/12/15
|
||||
*/
|
||||
public class HotbarInventory
|
||||
{
|
||||
public static void open(Player player, HotbarEditor editor)
|
||||
{
|
||||
Inventory inv = UtilServer.getServer().createInventory(null, 36, "Hotbar Editor");
|
||||
|
||||
for (int slot : Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23, 24, 25, 26))
|
||||
{
|
||||
inv.setItem(slot, getGlass(slot));
|
||||
}
|
||||
|
||||
HotbarLayout layout = editor.getLayout(player);
|
||||
|
||||
inv.setItem(layout.getSword() + 9, new ItemStack(Material.DIAMOND_SWORD, 1));
|
||||
inv.setItem(layout.getRod() + 9, new ItemStack(Material.FISHING_ROD, 1));
|
||||
inv.setItem(layout.getBow() + 9, new ItemStack(Material.BOW, 1));
|
||||
inv.setItem(layout.getArrows() + 9, new ItemStack(Material.ARROW, 1));
|
||||
|
||||
inv.setItem(30, new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + C.Bold + "Save").setLore(C.cGray + "Click to save layout.").build());
|
||||
inv.setItem(32, new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + C.Bold + "Cancel").setLore(C.cGray + "Click to cancel layout.").build());
|
||||
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
||||
private static ItemStack getGlass(int slot)
|
||||
{
|
||||
return new ItemBuilder(Material.STAINED_GLASS_PANE)
|
||||
.setData((short) 15)
|
||||
.setTitle((slot < 10 ? C.cAquaB + "⬇ Arrange Your Hotbar ⬇" : C.cAquaB + "⬆ Arrange Your Hotbar ⬆"))
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package nautilus.game.arcade.game.games.gladiators.hotbar;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 18/12/15
|
||||
*/
|
||||
public class HotbarLayout
|
||||
{
|
||||
private int sword;
|
||||
private int rod;
|
||||
private int bow;
|
||||
private int arrows;
|
||||
|
||||
public HotbarLayout(int sword, int rod, int bow, int arrows)
|
||||
{
|
||||
this.sword = sword;
|
||||
this.rod = rod;
|
||||
this.bow = bow;
|
||||
this.arrows = arrows;
|
||||
}
|
||||
|
||||
public int getSword()
|
||||
{
|
||||
return sword;
|
||||
}
|
||||
|
||||
public int getRod()
|
||||
{
|
||||
return rod;
|
||||
}
|
||||
|
||||
public int getBow()
|
||||
{
|
||||
return bow;
|
||||
}
|
||||
|
||||
public int getArrows()
|
||||
{
|
||||
return arrows;
|
||||
}
|
||||
|
||||
public void setSword(int sword)
|
||||
{
|
||||
this.sword = sword;
|
||||
}
|
||||
|
||||
public void setRod(int rod)
|
||||
{
|
||||
this.rod = rod;
|
||||
}
|
||||
|
||||
public void setBow(int bow)
|
||||
{
|
||||
this.bow = bow;
|
||||
}
|
||||
|
||||
public void setArrows(int arrows)
|
||||
{
|
||||
this.arrows = arrows;
|
||||
}
|
||||
|
||||
public int toDataSaveNumber()
|
||||
{
|
||||
String str = "";
|
||||
str += (getSword() + 1);
|
||||
str += (getRod() + 1);
|
||||
str += (getBow() + 1);
|
||||
str += (getArrows() + 1);
|
||||
|
||||
System.out.println("sword = " + sword);
|
||||
System.out.println("rod = " + rod);
|
||||
System.out.println("bow = " + bow);
|
||||
System.out.println("arrows = " + arrows);
|
||||
System.out.println("string = " + str);
|
||||
System.out.println("integer = " + Integer.parseInt(str));
|
||||
|
||||
|
||||
return Integer.parseInt(str);
|
||||
}
|
||||
|
||||
public int getEmpty()
|
||||
{
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
if (i == sword || i == rod || i == bow || i == arrows)
|
||||
continue;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package nautilus.game.arcade.game.games.gladiators.hotbar;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Item;
|
||||
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.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 18/12/15
|
||||
*/
|
||||
public class HotbarPageListener implements Listener
|
||||
{
|
||||
private HotbarEditor _editor;
|
||||
|
||||
public HotbarPageListener(HotbarEditor editor)
|
||||
{
|
||||
_editor = editor;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e)
|
||||
{
|
||||
if (!e.getInventory().getName().equals("Hotbar Editor"))
|
||||
return;
|
||||
|
||||
if (e.getCurrentItem() == null)
|
||||
return;
|
||||
|
||||
if (e.getAction().equals(InventoryAction.HOTBAR_SWAP) || e.getAction().equals(InventoryAction.HOTBAR_MOVE_AND_READD)){
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getClick().isShiftClick())
|
||||
{
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println(e.getClickedInventory().getName() + " : " + e.getInventory().getName());
|
||||
|
||||
if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
e.getWhoClicked().closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getClickedInventory() instanceof PlayerInventory || e.getInventory() instanceof PlayerInventory){
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK))
|
||||
{
|
||||
if (!e.getAction().equals(InventoryAction.PICKUP_ALL)){
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
e.getWhoClicked().closeInventory();
|
||||
_editor.saveLayout(((Player) e.getWhoClicked()), e.getClickedInventory());
|
||||
return;
|
||||
}
|
||||
|
||||
if ((e.getSlot() < 9 || e.getSlot() > 17))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e.getAction().equals(InventoryAction.PICKUP_ONE) || e.getAction().equals(InventoryAction.PLACE_ONE))){
|
||||
|
||||
if (!(e.getSlot() > 8 && e.getSlot() < 18))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// if (e.getAction().equals(InventoryAction.PLACE_ALL)
|
||||
// || e.getAction().equals(InventoryAction.PLACE_ONE)
|
||||
// || e.getAction().equals(InventoryAction.PLACE_SOME))
|
||||
// {
|
||||
// if (!(e.getSlot() > 8 && e.getSlot() < 18))
|
||||
// {
|
||||
// e.setCancelled(true);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onDrop(PlayerDropItemEvent e){
|
||||
if (e.getPlayer().getOpenInventory() == null)
|
||||
return;
|
||||
|
||||
if (e.getPlayer().getOpenInventory().getTopInventory() == null)
|
||||
return;
|
||||
|
||||
if (!e.getPlayer().getOpenInventory().getTopInventory().getName().equals("Hotbar Editor"))
|
||||
return;
|
||||
|
||||
if (!e.isCancelled())
|
||||
return;
|
||||
|
||||
e.setCancelled(false);
|
||||
Item i = e.getItemDrop();
|
||||
Inventory inv = e.getPlayer().getOpenInventory().getTopInventory();
|
||||
|
||||
if (i.getItemStack().getType().equals(Material.EMERALD_BLOCK))
|
||||
inv.setItem(30, new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + C.Bold + "Save").setLore(C.cGray + "Click to save layout.").build());
|
||||
else if (i.getItemStack().getType().equals(Material.REDSTONE_BLOCK))
|
||||
inv.setItem(32, new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + C.Bold + "Cancel").setLore(C.cGray + "Click to cancel layout.").build());
|
||||
else
|
||||
inv.addItem(i.getItemStack());
|
||||
|
||||
e.getPlayer().updateInventory();
|
||||
e.getPlayer().setItemOnCursor(null);
|
||||
|
||||
i.remove();
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ public class KitSkySquid extends SmashKit
|
||||
new PerkSmashStats(6, 1.5, 0.25, 5),
|
||||
new PerkDoubleJump("Double Jump", 0.9, 0.9, false),
|
||||
new PerkSuperSquid(),
|
||||
new PerkInkBlast(),
|
||||
new PerkInkBlast(7, 2),
|
||||
new PerkFishFlurry(),
|
||||
new PerkStormSquid()
|
||||
},
|
||||
@ -56,7 +56,7 @@ public class KitSkySquid extends SmashKit
|
||||
C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Ink Shotgun",
|
||||
new String[]
|
||||
{
|
||||
ChatColor.RESET + "Blasts 6 ink pellets out at high velocity.",
|
||||
ChatColor.RESET + "Blasts 7 ink pellets out at high velocity.",
|
||||
ChatColor.RESET + "They explode upon hitting something, dealing",
|
||||
ChatColor.RESET + "damage and knockback.",
|
||||
}));
|
||||
|
@ -67,6 +67,9 @@ public class Spleef extends SoloGame
|
||||
@EventHandler
|
||||
public void SnowballDamage(ProjectileHitEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Snowball))
|
||||
return;
|
||||
|
||||
|
@ -4,7 +4,6 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -19,23 +18,23 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityArrow;
|
||||
import net.minecraft.server.v1_8_R3.Item;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
@ -53,7 +52,6 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
|
||||
import nautilus.game.arcade.events.PlayerKitGiveEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
@ -694,6 +692,32 @@ public class TurfForts extends TeamGame
|
||||
continue;
|
||||
|
||||
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
// Apply velocity even if the player is sneaking near turf edges.
|
||||
|
||||
if (block.isEmpty() && player.isOnGround())
|
||||
{
|
||||
Block[] nearby = {
|
||||
block.getRelative(BlockFace.NORTH),
|
||||
block.getRelative(BlockFace.SOUTH),
|
||||
block.getRelative(BlockFace.WEST),
|
||||
block.getRelative(BlockFace.EAST),
|
||||
block.getRelative(BlockFace.NORTH_EAST),
|
||||
block.getRelative(BlockFace.NORTH_WEST),
|
||||
block.getRelative(BlockFace.SOUTH_EAST),
|
||||
block.getRelative(BlockFace.SOUTH_WEST)
|
||||
};
|
||||
|
||||
for (Block near : nearby)
|
||||
{
|
||||
if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL)
|
||||
{
|
||||
block = near;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (block.getTypeId() != 159 && block.getY() > 0)
|
||||
block = block.getRelative(BlockFace.DOWN);
|
||||
|
||||
@ -733,7 +757,7 @@ public class TurfForts extends TeamGame
|
||||
UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!"));
|
||||
}
|
||||
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
//On Own Turf
|
||||
else if ((team.GetColor() == ChatColor.RED && data == 14) || (team.GetColor() == ChatColor.AQUA && data == 3))
|
||||
@ -815,4 +839,58 @@ public class TurfForts extends TeamGame
|
||||
{
|
||||
return _enemyTurf.get(player);
|
||||
}
|
||||
|
||||
// Fixed by TeddyDev.
|
||||
@EventHandler
|
||||
public void blockGlitchFix(PlayerInteractEvent event)
|
||||
{
|
||||
if(event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if(event.getPlayer().isOnGround())
|
||||
return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if(block.getType() == Material.STAINED_CLAY || block.getType() == Material.WOOL)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block ground = player.getLocation().getBlock();
|
||||
while (ground.getType() == Material.AIR && ground.getLocation().getBlockY() >= 0)
|
||||
{
|
||||
ground = ground.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
||||
if(ground.isLiquid())
|
||||
{
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.VOID, 9001, false, false, false,
|
||||
"Border", "Border Damage");
|
||||
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.getLocation().distance(ground.getLocation()) < 4)
|
||||
return;
|
||||
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.VOID, 9001, false, false, false,
|
||||
"Border", "Border Damage");
|
||||
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
||||
}
|
||||
|
||||
// Keep ladders placed on ice when block updates occur.
|
||||
@EventHandler
|
||||
public void ladderDestroyFix(BlockPhysicsEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (block.getType() == Material.LADDER)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package nautilus.game.arcade.game.games.typewars;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.typewars.TypeWars.KillType;
|
||||
|
||||
public class StaffKillMonitorManager implements Listener
|
||||
{
|
||||
/**
|
||||
* Created by: Mysticate
|
||||
* Timestamp: December 30, 2015
|
||||
*/
|
||||
|
||||
private TypeWars _host;
|
||||
private String _command = "/words";
|
||||
|
||||
private NautHashMap<Player, Player> _monitoring = new NautHashMap<Player, Player>();
|
||||
|
||||
public StaffKillMonitorManager(TypeWars host)
|
||||
{
|
||||
_host = host;
|
||||
|
||||
host.Manager.registerEvents(this);;
|
||||
}
|
||||
|
||||
public TypeWars getHost()
|
||||
{
|
||||
return _host;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEnd(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.End)
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKill(MinionKillEvent event)
|
||||
{
|
||||
if (event.getType() == KillType.SPELL)
|
||||
return;
|
||||
|
||||
for (Player staff : _monitoring.keySet())
|
||||
{
|
||||
if (_monitoring.get(staff) == event.getPlayer())
|
||||
{
|
||||
UtilPlayer.message(staff, F.elem(C.cRedB + ">>") + F.name(event.getPlayer().getName()) + " killed " + F.elem(C.cGold + event.getMinion().getName()) + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (!_host.IsLive())
|
||||
return;
|
||||
|
||||
if (!_host.Manager.GetClients().hasRank(event.getPlayer(), Rank.HELPER))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
String[] message = event.getMessage().toLowerCase().split(" ");
|
||||
if (message.length == 0 || !message[0].equalsIgnoreCase(_command))
|
||||
return;
|
||||
|
||||
if (message.length == 1)
|
||||
{
|
||||
if (_monitoring.containsKey(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are no longer monitoring " + F.name(_monitoring.remove(event.getPlayer()).getName()) + "."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "Please enter a player to monitor!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String playerName = message[1];
|
||||
|
||||
Player player = UtilPlayer.searchOnline(event.getPlayer(), playerName, true);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
_monitoring.put(event.getPlayer(), player);
|
||||
UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are now monitoring " + F.name(player.getName()) + ". Type " + F.elem(_command) + " to stop."));
|
||||
}
|
||||
}
|
@ -5,6 +5,27 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -45,33 +66,10 @@ import nautilus.game.arcade.game.games.typewars.tutorial.TutorialTypeWars;
|
||||
import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent;
|
||||
import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.stats.TimeInGameStatTracker;
|
||||
import nautilus.game.arcade.world.WorldData;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TypeWars extends TeamGame
|
||||
{
|
||||
|
||||
private ArrayList<Minion> _activeMinions;
|
||||
private ArrayList<Minion> _deadMinions;
|
||||
private ArrayList<Minion> _finishedMinions;
|
||||
@ -114,6 +112,8 @@ public class TypeWars extends TeamGame
|
||||
"Kill your enemies Giant before they kill yours!"
|
||||
});
|
||||
|
||||
new StaffKillMonitorManager(this);
|
||||
|
||||
this.DeathOut = false;
|
||||
this.DamageTeamSelf = false;
|
||||
this.DamageSelf = false;
|
||||
|
@ -33,12 +33,18 @@ import nautilus.game.arcade.kit.SmashPerk;
|
||||
|
||||
public class PerkInkBlast extends SmashPerk implements IThrown
|
||||
{
|
||||
public PerkInkBlast()
|
||||
private int _bullets;
|
||||
private double _damagePerBullet;
|
||||
|
||||
public PerkInkBlast(int bullets, double damagePerBullet)
|
||||
{
|
||||
super("Ink Shotgun", new String[]
|
||||
{
|
||||
C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun"
|
||||
});
|
||||
|
||||
_bullets = bullets;
|
||||
_damagePerBullet = damagePerBullet;
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +81,7 @@ public class PerkInkBlast extends SmashPerk implements IThrown
|
||||
|
||||
UtilInv.Update(player);
|
||||
|
||||
for (int i=0 ; i<7 ; i++)
|
||||
for (int i=0 ; i < _bullets ; i++)
|
||||
{
|
||||
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),
|
||||
ItemStackFactory.Instance.CreateStack(Material.INK_SACK, (byte)0, 1, "Ink" + Math.random()));
|
||||
@ -113,7 +119,7 @@ public class PerkInkBlast extends SmashPerk implements IThrown
|
||||
|
||||
//Damage Event
|
||||
Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null,
|
||||
DamageCause.PROJECTILE, 3, true, true, false,
|
||||
DamageCause.PROJECTILE, _damagePerBullet, true, true, false,
|
||||
UtilEnt.getName(data.GetThrower()), GetName());
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.EXPLODE, target.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 12, ViewDist.LONG, UtilServer.getPlayers());
|
||||
|
Loading…
Reference in New Issue
Block a user