Merge remote-tracking branch 'origin/master' into foo

This commit is contained in:
fooify 2015-10-06 16:45:01 -07:00
commit a177b0cd43
211 changed files with 8809 additions and 1850 deletions

12
.gitignore vendored
View File

@ -17,6 +17,7 @@ update
Reference
/Plugins/.idea/workspace.xml
/Plugins/.idea/tasks.xml
/Plugins/out
BungeeCord
/Plugins/Mineplex.Bungee.Mineplexer/*.gitignore
@ -39,3 +40,14 @@ zBench
zMyst
zSotanna
zSotanna2
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fdt
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fdx
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fnm
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.frq
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.nrm
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.prx
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.tii
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.tis
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments.gen
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock

View File

@ -20,6 +20,7 @@
<element id="module-output" name="Mineplex.Database" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.PlayerCache" />
</root>
</artifact>
</component>

View File

@ -19,6 +19,7 @@
<element id="module-output" name="Mineplex.Database" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.PlayerCache" />
</root>
</artifact>
</component>

View File

@ -4,6 +4,7 @@
<option name="DEFAULT_COMPILER" value="Javac" />
<excludeFromCompile>
<directory url="file://$PROJECT_DIR$/Nautilus.Game.PvP" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.ServerMonitor" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.Game.Clans" includeSubdirectories="true" />
</excludeFromCompile>
<resourceExtensions />

View File

@ -11,7 +11,6 @@
<module fileurl="file://$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" filepath="$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" filepath="$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" filepath="$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" group="Bungee" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" />

View File

@ -86,6 +86,9 @@
<fileset dir="../Mineplex.ServerData/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.PlayerCache/bin">
<include name="**/*.class"/>
</fileset>
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
<zipfileset src="../Libraries/httpclient-4.2.jar" />
@ -152,6 +155,9 @@
<fileset dir="../Mineplex.Database/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.PlayerCache/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.ServerData/bin">
<include name="**/*.class"/>
</fileset>
@ -198,6 +204,9 @@
<fileset dir="../Mineplex.ServerData/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.PlayerCache/bin">
<include name="**/*.class"/>
</fileset>
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
<zipfileset src="../Libraries/httpclient-4.2.jar" />
@ -234,6 +243,9 @@
<fileset dir="../Mineplex.ServerData/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.PlayerCache/bin">
<include name="**/*.class"/>
</fileset>
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
<zipfileset src="../Libraries/httpclient-4.2.jar" />

Binary file not shown.

View File

@ -96,6 +96,8 @@ public class LobbyBalancer implements Listener, Runnable
if (timeSpentInLock > 50)
System.out.println("[==] TIMING [==] Locked loading servers for " + timeSpentInLock + "ms");
_lobbyIndex = 0;
}
}
}

View File

@ -54,12 +54,13 @@ public class MotdManager implements Listener, Runnable
Region.ALL, GlobalMotd.class, "globalMotd");
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
String motdLine = " §b§l◄§f§lNEW GAME§b§l► §f§l◄§b§lEVOLUTION§f§l► §b§l◄§f§lNEW GAME§b§l►";
//String motdLine = " §f§l◄ §a§lCarl the Creeper§f§l ▬ §c§l75% OFF SALE§f§l ►";
//String motdLine = " §d§lRank Sale §a§l40% Off");
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", motdLine);
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", motdLine);
System.out.println("Updated Bungee MOTD");
}
}
@ -97,23 +98,7 @@ public class MotdManager implements Listener, Runnable
public void updateMainMotd(String headline, String motdLine)
{
List<String> motdLines = new ArrayList<String>();
String colorStripped = ChatColor.stripColor(motdLine);
if (colorStripped.trim().length() > 45)
motdLine = motdLine.trim().substring(0, 45);
else
{
String trimmed = colorStripped.trim();
int count = trimmed.length();
int marker = 0;
while ((45 - count) / 2 * 1.55 > marker)
{
motdLine = " " + motdLine;
marker++;
}
}
motdLines.add(motdLine);
_repository.addElement(new GlobalMotd("MainMotd", headline, motdLines));

View File

@ -24,7 +24,6 @@ public class PlayerCount implements Listener, Runnable
{
private DataRepository<BungeeServer> _repository;
private DataRepository<BungeeServer> _secondRepository;
private UUID _uuid;
private Region _region;
private ListenerInfo _listenerInfo;
@ -34,7 +33,6 @@ public class PlayerCount implements Listener, Runnable
public PlayerCount(Plugin plugin)
{
_uuid = UUID.randomUUID();
_region = !new File("eu.dat").exists() ? Region.US : Region.EU;
_plugin = plugin;
@ -86,7 +84,7 @@ public class PlayerCount implements Listener, Runnable
*/
private BungeeServer generateSnapshot()
{
String name = _uuid.toString(); // Use random UUID for unique id name.
String name = _listenerInfo.getHost().getAddress().getHostAddress();
String host = _listenerInfo.getHost().getAddress().getHostAddress();
int port = _listenerInfo.getHost().getPort();
boolean connected = InternetStatus.isConnected();

View File

@ -1,6 +1,5 @@
package mineplex.bungee.playerStats;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@ -17,9 +16,8 @@ import net.md_5.bungee.event.EventHandler;
public class PlayerStats implements Listener, Runnable
{
private Plugin _plugin;
private PlayerStatsRepository _repository;
private PlayerStatsRepository _repository;
private PlayerCache _playerCache = new PlayerCache();
private HashSet<UUID> _retrievingPlayerInfo = new HashSet<UUID>();
public PlayerStats(Plugin plugin)
@ -52,7 +50,7 @@ public class PlayerStats implements Listener, Runnable
boolean addOrUpdatePlayer = false;
playerInfo = _playerCache.getPlayer(uuid);
playerInfo = PlayerCache.getInstance().getPlayer(uuid);
if (playerInfo == null)
{
@ -80,12 +78,11 @@ public class PlayerStats implements Listener, Runnable
}
else
playerInfo = updatedPlayerInfo;
_playerCache.addPlayer(playerInfo);
}
playerInfo.setSessionId(_repository.updatePlayerStats(playerInfo.getId(), ipInfo.id));
_playerCache.addPlayer(playerInfo);
playerInfo.updateLoginTime();
PlayerCache.getInstance().addPlayer(playerInfo);
}
finally
{
@ -106,13 +103,13 @@ public class PlayerStats implements Listener, Runnable
PlayerInfo playerInfo = null;
playerInfo = _playerCache.getPlayer(uuid);
playerInfo = PlayerCache.getInstance().getPlayer(uuid);
int timeout = 5;
while (playerInfo == null && _retrievingPlayerInfo.contains(uuid) && timeout <= 5)
{
playerInfo = _playerCache.getPlayer(uuid);
playerInfo = PlayerCache.getInstance().getPlayer(uuid);
if (playerInfo != null)
break;
@ -140,6 +137,6 @@ public class PlayerStats implements Listener, Runnable
@Override
public void run()
{
_playerCache.clean();
PlayerCache.getInstance().clean();
}
}

View File

@ -0,0 +1,27 @@
package mineplex.bungee.playerTracker;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.PlayerJoinCommand;
import mineplex.serverdata.commands.ServerCommand;
public class PlayerJoinHandler implements CommandCallback
{
private PlayerTracker _playerTracker;
public PlayerJoinHandler(PlayerTracker playerTracker)
{
_playerTracker = playerTracker;
}
@SuppressWarnings("deprecation")
@Override
public void run(ServerCommand command)
{
if (command instanceof PlayerJoinCommand)
{
PlayerJoinCommand joinCommand = (PlayerJoinCommand)command;
_playerTracker.kickPlayerIfOnline(joinCommand.getUuid());
}
}
}

View File

@ -1,19 +1,25 @@
package mineplex.bungee.playerTracker;
import java.io.File;
import java.util.HashSet;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import mineplex.serverdata.Region;
import mineplex.serverdata.commands.ServerCommandManager;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.data.PlayerStatus;
import mineplex.serverdata.redis.RedisDataRepository;
import mineplex.serverdata.servers.ServerManager;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;
public class PlayerTracker implements Listener
public class PlayerTracker implements Listener, Runnable
{
// Default period before status expiry (8 hours)
private static final int DEFAULT_STATUS_TIMEOUT = 60 * 60 * 8;
@ -21,6 +27,8 @@ public class PlayerTracker implements Listener
// Repository storing player status' across network.
private DataRepository<PlayerStatus> _repository;
private HashSet<String> _onlineUUIDs = new HashSet<String>();
private Plugin _plugin;
public PlayerTracker(Plugin plugin)
@ -28,11 +36,14 @@ public class PlayerTracker implements Listener
_plugin = plugin;
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.MINUTES);
Region region = !new File("eu.dat").exists() ? Region.US : Region.EU;
_repository = new RedisDataRepository<PlayerStatus>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
region, PlayerStatus.class, "playerStatus");
ServerCommandManager.getInstance().registerCommandType("PlayerJoinCommand", mineplex.serverdata.commands.PlayerJoinCommand.class, new PlayerJoinHandler(this));
System.out.println("Initialized PlayerTracker.");
}
@ -59,5 +70,42 @@ public class PlayerTracker implements Listener
_repository.removeElement(event.getPlayer().getName().toLowerCase());
}
});
_onlineUUIDs.remove(event.getPlayer().getUniqueId());
}
@EventHandler
public void playerConnect(final PostLoginEvent event)
{
_onlineUUIDs.add(event.getPlayer().getUniqueId().toString());
}
@Override
public void run()
{
HashSet<String> onlineUUIDs = new HashSet<String>();
for (ProxiedPlayer player : _plugin.getProxy().getPlayers())
{
onlineUUIDs.add(player.getUniqueId().toString());
}
_onlineUUIDs = onlineUUIDs;
}
public boolean isPlayerOnline(String uuid)
{
return _onlineUUIDs.contains(uuid);
}
public void kickPlayerIfOnline(String uuid)
{
if (_onlineUUIDs.contains(uuid))
{
ProxiedPlayer player = _plugin.getProxy().getPlayer(UUID.fromString(uuid));
if (player != null)
player.disconnect("You have logged in from another location.");
}
}
}

View File

@ -141,7 +141,7 @@ public class BungeeRotator
else
euPlayers += server.getPlayerCount();
System.out.println(server.getRegion().toString() + " " + server.getPublicAddress() + " " + server.getPlayerCount() + "/" + server.getPlayerCount());
System.out.println(server.getRegion().toString() + " " + server.getName() + " " + server.getPublicAddress() + " " + server.getPlayerCount() + "/" + server.getPlayerCount());
}
System.out.println("US Players : " + usPlayers);
@ -247,6 +247,9 @@ public class BungeeRotator
new ApiDeleteCall("https://api.dnsmadeeasy.com/V2.0/dns/managed/", 962728, "/records?" + idBuilder.toString()).Execute();
log("Deleted " + recordsToDelete.size() + " records.");
}
_repository.clean();
_secondRepository.clean();
}
/*

View File

@ -10,6 +10,7 @@
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>

View File

@ -8,6 +8,7 @@ import mineplex.core.common.util.UtilPlayer;
public enum Rank
{
//Staff
LT("LT", ChatColor.DARK_RED),
OWNER("Owner", ChatColor.DARK_RED),
DEVELOPER("Dev", ChatColor.RED),
@ -21,36 +22,48 @@ public enum Rank
MEDIA("Media", ChatColor.BLUE),
EVENT("Event", ChatColor.WHITE),
//Staff ^^
//Media
YOUTUBE("YouTube", ChatColor.RED),
YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE),
TWITCH("Twitch", ChatColor.DARK_PURPLE),
LEGEND("Legend", ChatColor.GREEN),
HERO("Hero", ChatColor.LIGHT_PURPLE),
ULTRA("Ultra", ChatColor.AQUA),
//Player
LEGEND("Legend", ChatColor.GREEN, true),
HERO("Hero", ChatColor.LIGHT_PURPLE, true),
ULTRA("Ultra", ChatColor.AQUA, true),
ALL("", ChatColor.WHITE);
private ChatColor Color;
private ChatColor _color;
private boolean _donor;
public String Name;
Rank(String name, ChatColor color)
{
Color = color;
_color = color;
Name = name;
_donor = false;
}
public boolean Has(Rank rank)
Rank(String name, ChatColor color, boolean donor)
{
return Has(null, rank, false);
_color = color;
Name = name;
_donor = donor;
}
public boolean Has(Player player, Rank rank, boolean inform)
public boolean has(Rank rank)
{
return Has(player, rank, null, inform);
return has(null, rank, false);
}
public boolean Has(Player player, Rank rank, Rank[] specific, boolean inform)
public boolean has(Player player, Rank rank, boolean inform)
{
return has(player, rank, null, inform);
}
public boolean has(Player player, Rank rank, Rank[] specific, boolean inform)
{
//Specific Rank
if (specific != null)
@ -79,7 +92,7 @@ public enum Rank
return false;
}
public String GetTag(boolean bold, boolean uppercase)
public String getTag(boolean bold, boolean uppercase)
{
if (Name.equalsIgnoreCase("ALL"))
return "";
@ -88,12 +101,17 @@ public enum Rank
if (uppercase)
name = Name.toUpperCase();
if (bold) return Color + C.Bold + name;
else return Color + name;
if (bold) return _color + C.Bold + name;
else return _color + name;
}
public ChatColor GetColor()
public ChatColor getColor()
{
return Color;
return _color;
}
public boolean isDonor()
{
return _donor;
}
}

View File

@ -0,0 +1,232 @@
package mineplex.core.common.lang;
import java.text.Format;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class IntlString
{
public static IntlString[] toIntl(String... strings)
{
IntlString[] intl = new IntlString[strings.length];
for (int i = 0; i < strings.length; i++) {
final String string = strings[i];
intl[i] = new IntlString("")
{
public String tr(Locale locale)
{
return string;
}
};
}
return intl;
}
/**
* An empty {@link IntlString}.
*/
public static final IntlString EMPTY = toIntl("")[0];
private final Argument<String> key;
private final List<Argument<Object>> arguments = new ArrayList<>();
public IntlString(String key, ChatColor... styles)
{
this.key = new Argument<>(key, styles);
}
IntlString(String key, String style)
{
this.key = new Argument<>(key, style);
}
private IntlString arg(Argument<Object> argument)
{
IntlString result = new IntlString(getKey().getArgument(), getKey().getStyle());
result.arguments.addAll(getArguments());
result.arguments.add(argument);
return result;
}
public Argument<String> getKey()
{
return key;
}
public List<Argument<Object>> getArguments()
{
return Collections.unmodifiableList(arguments);
}
public IntlString arg(Object value, ChatColor... styles)
{
return arg(new Argument<>(value, styles));
}
public IntlString arg(Object value, String style)
{
return arg(new Argument<>(value, style));
}
public String tr()
{
return tr(Locale.getDefault());
}
public String tr(Entity entity)
{
if (entity instanceof Player)
return tr((Player) entity);
else
return tr();
}
public String tr(Player player)
{
return tr(Lang.getPlayerLocale(player));
}
public String tr(Locale locale)
{
if (locale == null)
locale = Locale.getDefault();
String formatString = Lang.get(getKey().getArgument(), locale);
if (getKey().getArgument().equals("stats.achievements.disabled.requires.0.players"))
{
int x = 8;
}
if (getArguments().isEmpty())
return getKey().getStyle() + formatString;
else
{
MessageFormat format = new MessageFormat(formatString, locale);
Format[] formats = format.getFormatsByArgumentIndex();
Object[] argArray = new Object[getArguments().size()];
for (int i = 0; i < formats.length; i++)
{
argArray[i] = getArguments().get(i);
if (argArray[i] instanceof IntlString)
argArray[i] = ((IntlString) argArray[i]).tr(locale);
if (formats[i] != null)
{
argArray[i] = formats[i].format(argArray[i]);
format.setFormatByArgumentIndex(i, null);
}
String style = getArguments().get(i).getStyle();
if (!style.isEmpty())
argArray[i] = style + argArray[i] + ChatColor.RESET;
argArray[i] = argArray[i] + getKey().getStyle();
}
return getKey().getStyle() + format.format(argArray, new StringBuffer(), null).toString();
}
}
@Override
public boolean equals(Object o)
{
if (!(o instanceof IntlString))
return false;
IntlString s = (IntlString) o;
return getKey().equals(s.getKey()) && getArguments().equals(s.getArguments());
}
@Override
public int hashCode()
{
return toString().hashCode();
}
@Override
public String toString()
{
return toEnglishString();
}
public String toEnglishString()
{
return tr(Locale.ENGLISH);
}
private static class Argument<T>
{
private final T argument;
private final String style;
public Argument(T value, ChatColor... styles)
{
this.argument = value;
String s = "";
ChatColor color = null;
for (ChatColor style : styles)
{
if (style.isColor())
color = style;
else if (style.isFormat())
s += style;
}
this.style = ChatColor.getLastColors((color == null ? "" : color) + s);
}
public Argument(T value, String style)
{
this.argument = value;
this.style = style == null ? "" : ChatColor.getLastColors(style);
}
public T getArgument()
{
return argument;
}
public String getStyle()
{
return style;
}
@Override
public boolean equals(Object o)
{
if (!(o instanceof Argument))
return false;
Argument<?> p = (Argument<?>) o;
return getArgument().equals(p.getArgument()) && getStyle().equals(p.getStyle());
}
@Override
public int hashCode()
{
return toString().hashCode();
}
@Override
public String toString()
{
return getStyle() + getArgument();
}
}
}

View File

@ -0,0 +1,154 @@
package mineplex.core.common.lang;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import mineplex.core.common.util.F;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public final class Lang
{
public static interface PlayerLocaleFunction
{
public Locale getLocaleOfPlayer(Player player);
}
private static PlayerLocaleFunction _playerLocaleFunction = null;
private static final Map<Locale, ResourceBundle> _localeResourceBundles = Collections.synchronizedMap(new HashMap<Locale, ResourceBundle>());
public Lang()
{
init();
}
private void init()
{
System.out.println(F.main("i18n","Attempting to initialize resource bundles..."));
try
{
// Locales over which we should iterate and load.
for (Locale loc : new Locale[] {
Locale.ENGLISH,
Locale.GERMAN
})
{
ResourceBundle bundle = ResourceBundle.getBundle("mineplex.core.common.lang.MineplexBundle", loc);
_localeResourceBundles.put(loc, bundle);
System.out.println("Loaded " + loc.toString() + "...");
}
}
catch (MissingResourceException e)
{
System.err.println("AN ERROR OCCURED WHILE ATTEMPTING TO LOAD RESOURCE LOCALES");
// For now at least, crash the runtime.
throw new RuntimeException(e);
}
}
public static PlayerLocaleFunction getPlayerLocaleFunction()
{
return _playerLocaleFunction;
}
public static void setPlayerLocaleFunction(PlayerLocaleFunction playerLocaleFunction)
{
_playerLocaleFunction = playerLocaleFunction;
}
public static Locale getPlayerLocale(Player player)
{
if (getPlayerLocaleFunction() == null)
return Locale.getDefault();
else
return getPlayerLocaleFunction().getLocaleOfPlayer(player);
}
public static ResourceBundle getResourceBundle(Locale locale)
{
synchronized (_localeResourceBundles)
{
if (_localeResourceBundles.containsKey(locale))
return _localeResourceBundles.get(locale);
else
{
return _localeResourceBundles.get(Locale.ENGLISH);
}
}
}
public static ResourceBundle getBestResourceBundle(Locale locale)
{
ResourceBundle bundle = getResourceBundle(locale);
if (bundle == null && !locale.equals(Locale.getDefault()))
bundle = getResourceBundle(Locale.getDefault());
if (bundle == null && !locale.equals(Locale.ENGLISH))
bundle = getResourceBundle(Locale.ENGLISH);
return bundle;
}
/**
* Shorthand method for obtaining and translating a key.
*/
public static String tr(String key, Entity entity, Object... args)
{
IntlString string = key(key);
for (Object a : args)
string.arg(a);
return string.tr(entity);
}
public static String get(String key)
{
return get(key, (Locale) null);
}
public static String get(String key, Locale locale)
{
if (key == null)
return null;
else if (key.isEmpty())
return "";
else
{
if (locale == null)
locale = Locale.getDefault();
ResourceBundle bundle = getBestResourceBundle(locale);
if (bundle == null)
return null;
return bundle.getString(key);
}
}
public static String get(String key, Player player)
{
return get(key, getPlayerLocale(player));
}
public static IntlString key(String key, ChatColor... styles)
{
return new IntlString(key, styles);
}
public static IntlString key(String key, String style)
{
return new IntlString(key, style);
}
}

View File

@ -95,15 +95,15 @@ public class F
public static String help(String cmd, String body, Rank rank)
{
return rank.GetColor() + cmd + " " + C.mBody + body + " " + rank(rank);
return rank.getColor() + cmd + " " + C.mBody + body + " " + rank(rank);
}
public static String rank(Rank rank)
{
if (rank == Rank.ALL)
return rank.GetColor() + "Player";
return rank.getColor() + "Player";
return rank.GetTag(false, false);
return rank.getTag(false, false);
}
public static String value(String variable, String value)

View File

@ -69,6 +69,11 @@ public class MapUtil
{
QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), setTo);
}
public static void QuickChangeBlockAt(Location location, Material setTo, byte data)
{
QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), setTo, data);
}
public static void QuickChangeBlockAt(Location location, int id, byte data)
{

View File

@ -5,10 +5,8 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -251,6 +249,25 @@ public class UtilAlg
return bestLoc;
}
public static Location findFurthest(Location mid, ArrayList<Location> locs)
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : locs)
{
double dist = UtilMath.offset(mid, loc);
if (bestLoc == null || dist > bestDist)
{
bestLoc = loc;
bestDist = dist;
}
}
return bestLoc;
}
public static boolean isInPyramid(Vector a, Vector b, double angleLimit)
{
return (Math.abs(GetPitch(a) - GetPitch(b)) < angleLimit) && (Math.abs(GetYaw(a) - GetYaw(b)) < angleLimit);
@ -298,6 +315,42 @@ public class UtilAlg
return bestLoc;
}
public static Location getLocationAwayFromOtherLocations(ArrayList<Location> locs, ArrayList<Location> players)
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : locs)
{
double closest = -1;
for (Location player : players)
{
//Different Worlds
if (!player.getWorld().equals(loc.getWorld()))
continue;
double dist = UtilMath.offsetSquared(player, loc);
if (closest == -1 || dist < closest)
{
closest = dist;
}
}
if (closest == -1)
continue;
if (bestLoc == null || closest > bestDist)
{
bestLoc = loc;
bestDist = closest;
}
}
return bestLoc;
}
public static Location getLocationNearPlayers(ArrayList<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
{
Location bestLoc = null;
@ -353,4 +406,21 @@ public class UtilAlg
return bestLoc;
}
public static Location getNearestCornerLocation(Location near, Block block)
{
ArrayList<Location> corners = new ArrayList<Location>();
corners.add(block.getLocation().clone());
corners.add(block.getLocation().clone().add(.999, 0, 0));
corners.add(block.getLocation().clone().add(.999, 0, .999));
corners.add(block.getLocation().clone().add(0, 0, .999));
corners.add(block.getLocation().clone().add(0, .999, 0));
corners.add(block.getLocation().clone().add(.999, .999, 0));
corners.add(block.getLocation().clone().add(.999, .999, .999));
corners.add(block.getLocation().clone().add(0, .999, .999));
return UtilAlg.findClosest(near, corners);
}
}

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
import net.minecraft.server.v1_7_R4.EntityBat;
import net.minecraft.server.v1_7_R4.EntityCreature;
import net.minecraft.server.v1_7_R4.EntityEnderDragon;
@ -26,7 +27,9 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.entity.Creature;
@ -36,8 +39,6 @@ import org.bukkit.entity.Giant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
public class UtilEnt
{
@ -495,10 +496,14 @@ public class UtilEnt
public static boolean isGrounded(Entity ent)
{
if (ent instanceof CraftEntity)
return ((CraftEntity)ent).getHandle().onGround;
return UtilBlock.solid(ent.getLocation().getBlock().getRelative(BlockFace.DOWN));
AxisAlignedBB box = ((CraftEntity)ent).getHandle().boundingBox;
Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c);
Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f);
for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){
if(UtilBlock.solid(b)) return true;
}
return false;
}
public static void PlayDamageSound(LivingEntity damagee)

View File

@ -1,5 +1,7 @@
package mineplex.core.common.util;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
@ -8,6 +10,7 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.Vector;
@ -68,5 +71,29 @@ public class UtilFirework
public static void playFirework(Location loc, Type type, Color color, boolean flicker, boolean trail)
{
playFirework(loc, FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build());
}
public static void packetPlayFirework(Player player, Location loc, Type type, Color color, boolean flicker, boolean trail)
{
Firework firework = (Firework) loc.getWorld().spawn(loc, Firework.class);
FireworkEffect effect = FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build();
FireworkMeta data = (FireworkMeta) firework.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(effect);
firework.setFireworkMeta(data);
((CraftFirework) firework).getHandle().expectedLifespan = 1;
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(firework.getEntityId());
for (Player viewing : UtilServer.getPlayers())
{
if (player == viewing)
continue;
UtilPlayer.sendPacket(viewing, packet);
}
}
}

View File

@ -12,6 +12,10 @@ import org.bukkit.inventory.ItemStack;
public class UtilItem
{
private static final Material[] FOOD_LIST = { Material.APPLE, Material.BAKED_POTATO, Material.BREAD, Material.CARROT, Material.CARROT_ITEM, Material.COOKED_CHICKEN,
Material.COOKED_FISH, Material.GRILLED_PORK, Material.COOKIE, Material.GOLDEN_APPLE, Material.GOLDEN_CARROT, Material.MELON, Material.MUSHROOM_SOUP, Material.POISONOUS_POTATO,
Material.PUMPKIN_PIE, Material.RAW_BEEF, Material.RAW_CHICKEN, Material.RAW_FISH, Material.PORK, Material.ROTTEN_FLESH, Material.SPIDER_EYE, Material.COOKED_BEEF};
public static LinkedList<ItemContainer> matchItem(Player caller, String items, boolean inform)
{
LinkedList<ItemContainer> matchList = new LinkedList<ItemContainer>();
@ -136,4 +140,20 @@ public class UtilItem
return item.getType() + ":" + item.getAmount() + ":" + item.getDurability() + ":" + data;
}
public static boolean isFood(ItemStack item)
{
return item == null ? false : isFood(item.getType());
}
public static boolean isFood(Material material)
{
for (Material food : FOOD_LIST)
{
if (food.equals(material))
return true;
}
return false;
}
}

View File

@ -6,23 +6,23 @@ public class UtilSkull
{
public static byte getSkullData(Entity entity)
{
if (entity instanceof Skeleton)
{
Skeleton sk = ((Skeleton) entity);
if (sk.getSkeletonType() == Skeleton.SkeletonType.WITHER)
return 1;
else return 0;
}
else if (entity instanceof Zombie || entity instanceof Giant)
{
if (entity == null)
return 0;
return getSkullData(entity.getType());
}
public static byte getSkullData(EntityType type)
{
if (type == EntityType.SKELETON)
return 0;
if (type == EntityType.WITHER)
return 1;
if (type == EntityType.ZOMBIE || type == EntityType.GIANT)
return 2;
}
else if (entity instanceof Creeper)
{
if (type == EntityType.CREEPER)
return 4;
}
else
return 3;
return 3;
}
public static boolean isPlayerHead(byte data)
@ -31,52 +31,54 @@ public class UtilSkull
}
public static String getPlayerHeadName(Entity entity)
{
return getPlayerHeadName(entity.getType());
}
public static String getPlayerHeadName(EntityType entity)
{
String name = "MHF_Alex";
// order is important for some of these
if (entity instanceof Blaze)
if (entity == EntityType.BLAZE)
name = "MHF_Blaze";
else if (entity instanceof CaveSpider)
else if (entity == EntityType.CAVE_SPIDER)
name = "MHF_CaveSpider";
else if (entity instanceof Spider)
else if (entity == EntityType.SPIDER)
name = "MHF_Spider";
else if (entity instanceof Chicken)
else if (entity == EntityType.CHICKEN)
name = "MHF_Chicken";
else if (entity instanceof MushroomCow)
else if (entity == EntityType.MUSHROOM_COW)
name = "MHF_MushroomCow";
else if (entity instanceof Cow)
else if (entity == EntityType.COW)
name = "MHF_Cow";
else if (entity instanceof Creeper)
else if (entity == EntityType.CREEPER)
name = "MHF_Creeper";
else if (entity instanceof Enderman)
else if (entity == EntityType.ENDERMAN)
name = "MHF_Enderman";
else if (entity instanceof Ghast)
else if (entity == EntityType.GHAST)
name = "MHF_Ghast";
else if (entity instanceof Golem)
else if (entity == EntityType.IRON_GOLEM)
name = "MHF_Golem";
else if (entity instanceof PigZombie)
else if (entity == EntityType.PIG_ZOMBIE)
name = "MHF_PigZombie";
else if (entity instanceof MagmaCube)
else if (entity == EntityType.MAGMA_CUBE)
name = "MHF_LavaSlime";
else if (entity instanceof Slime)
else if (entity == EntityType.SLIME)
name = "MHF_Slime";
else if (entity instanceof Ocelot)
else if (entity == EntityType.OCELOT)
name = "MHF_Ocelot";
else if (entity instanceof PigZombie)
name = "MHF_PigZombie";
else if (entity instanceof Pig)
else if (entity == EntityType.PIG)
name = "MHF_Pig";
else if (entity instanceof Sheep)
name = "MHF_Pig";
else if (entity instanceof Squid)
else if (entity == EntityType.SHEEP)
name = "MHF_Sheep";
else if (entity == EntityType.SQUID)
name = "MHF_Squid";
else if (entity instanceof HumanEntity)
else if (entity == EntityType.PLAYER)
name = "MHF_Steve";
else if (entity instanceof Villager)
else if (entity == EntityType.VILLAGER)
name = "MHF_Villager";
return name;
}
}

View File

@ -14,5 +14,6 @@
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.PlayerCache"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,5 +1,6 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7

View File

@ -20,5 +20,6 @@
<orderEntry type="library" name="commons-dbcp2" level="project" />
<orderEntry type="module" module-name="Classpath.Dummy" />
<orderEntry type="library" name="NoCheatPlus" level="project" />
<orderEntry type="module" module-name="Mineplex.PlayerCache" />
</component>
</module>

View File

@ -0,0 +1,29 @@
package mineplex.core;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilItem;
public class FoodDupeFix extends MiniPlugin
{
public FoodDupeFix(JavaPlugin plugin)
{
super("Food Dupe Fix", plugin);
}
// Use Lowest priority so we get called first event.getItem isn't changed
@EventHandler(priority = EventPriority.LOWEST)
public void fixFoodDupe(PlayerItemConsumeEvent event)
{
if (UtilItem.isFood(event.getItem()))
{
if (!event.getItem().equals(event.getPlayer().getItemInHand()))
{
event.setCancelled(true);
}
}
}
}

View File

@ -22,7 +22,7 @@ public class TablistFix extends MiniPlugin
// This is sort of experimental!
@EventHandler(priority = EventPriority.MONITOR)
public void onJoin(PlayerJoinEvent event)
{
{/*
final Player player = event.getPlayer();
runSyncLater(new Runnable()
{
@ -49,5 +49,6 @@ public class TablistFix extends MiniPlugin
}
}
}, 20L);
*/
}
}

View File

@ -1,33 +0,0 @@
package mineplex.core.account;
import java.util.UUID;
import mineplex.serverdata.data.Data;
public class AccountCache implements Data
{
private UUID _uuid;
private Integer _id;
public AccountCache(UUID uuid, int id)
{
_uuid = uuid;
_id = id;
}
public UUID getUUID()
{
return _uuid;
}
public int getId()
{
return _id;
}
@Override
public String getDataId()
{
return _uuid.toString();
}
}

View File

@ -1,12 +1,14 @@
package mineplex.core.account;
import mineplex.core.common.Rank;
import mineplex.serverdata.Utility;
import org.bukkit.entity.Player;
public class CoreClient
{
private int _accountId = -1;
private long _networkSessionLoginTime;
private String _name;
private String _disguisedAs;
private Player _player;
@ -18,6 +20,7 @@ public class CoreClient
{
_player = player;
_name = player.getName();
_networkSessionLoginTime = Utility.currentTimeMillis();
}
public CoreClient(String name)
@ -58,6 +61,9 @@ public class CoreClient
public Rank GetRank()
{
if (_rank == null)
_rank = Rank.ALL;
return _rank;
}
@ -65,6 +71,11 @@ public class CoreClient
{
_rank = rank;
}
public long getNetworkSessionLoginTime()
{
return _networkSessionLoginTime;
}
public String getDisguisedAs()
{
@ -95,4 +106,9 @@ public class CoreClient
public void setDisguised(boolean disguised) {
this._disguised = disguised;
}
public void setNetworkSessionLoginTime(long loginTime)
{
_networkSessionLoginTime = loginTime;
}
}

View File

@ -22,10 +22,8 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.BungeeServer;
import mineplex.serverdata.redis.RedisDataRepository;
import mineplex.serverdata.servers.ServerManager;
import mineplex.playerCache.PlayerCache;
import mineplex.playerCache.PlayerInfo;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -48,7 +46,6 @@ public class CoreClientManager extends MiniPlugin
private AccountRepository _repository;
private NautHashMap<String, CoreClient> _clientList;
private HashSet<String> _duplicateLoginGlitchPreventionList;
private RedisDataRepository<AccountCache> _accountCacheRepository;
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
private LinkedList<IQuerylessLoginProcessor> _querylessLoginProcessors = new LinkedList<IQuerylessLoginProcessor>();
@ -66,9 +63,6 @@ public class CoreClientManager extends MiniPlugin
_repository = new AccountRepository(plugin, webServer);
_clientList = new NautHashMap<String, CoreClient>();
_duplicateLoginGlitchPreventionList = new HashSet<String>();
_accountCacheRepository = new RedisDataRepository<AccountCache>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
Region.ALL, AccountCache.class, "accountCache");
}
public AccountRepository getRepository()
@ -126,7 +120,14 @@ public class CoreClientManager extends MiniPlugin
if(client.getDisguisedAs().equalsIgnoreCase(name))
return client;
}
return _clientList.get(name);
CoreClient client = _clientList.get(name);
if (client == null)
{
client = new CoreClient(name);
}
return client;
}
}
@ -185,7 +186,7 @@ public class CoreClientManager extends MiniPlugin
_clientsProcessing.decrementAndGet();
}
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR))
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(Rank.MODERATOR))
{
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
{
@ -251,7 +252,15 @@ public class CoreClientManager extends MiniPlugin
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
if (client.getAccountId() > 0)
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6);
{
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
if (playerInfo != null)
{
playerInfo.setAccountId(client.getAccountId());
PlayerCache.getInstance().addPlayer(playerInfo);
}
}
}
catch (Exception exception)
{
@ -295,7 +304,7 @@ public class CoreClientManager extends MiniPlugin
TimingManager.stop(client.GetPlayerName() + " GetClient.");
token = gson.fromJson(response, ClientToken.class);
client.SetRank(Rank.valueOf(token.Rank));
// _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
@ -322,17 +331,15 @@ public class CoreClientManager extends MiniPlugin
TimingManager.stop(client.GetPlayerName() + " LoadClient Total.");
System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId());
if (client.getAccountId() > 0)
{
try
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
if (playerInfo != null)
{
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6);
}
catch (Exception e)
{
e.printStackTrace();
client.setNetworkSessionLoginTime(playerInfo.getLoginTime());
playerInfo.setAccountId(client.getAccountId());
PlayerCache.getInstance().addPlayer(playerInfo);
}
}
@ -363,7 +370,7 @@ public class CoreClientManager extends MiniPlugin
// Reserved Slot Check
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers())
{
if (client.GetRank().Has(event.getPlayer(), Rank.ULTRA, false))
if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false))
{
event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED);
@ -542,11 +549,6 @@ public class CoreClientManager extends MiniPlugin
if (client == null)
return false;
return client.GetRank().Has(rank);
}
public int getCachedClientAccountId(UUID uuid)
{
return _accountCacheRepository.getElement(uuid.toString()).getId();
return client.GetRank().has(rank);
}
}

View File

@ -29,7 +29,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
if (Plugin.Get(caller).GetRank() == Rank.JNR_DEV && !testServer)
{
F.main(Plugin.getName(), F.elem(Rank.JNR_DEV.GetTag(true, true)) + "s are only permitted to set ranks on test servers!");
F.main(Plugin.getName(), F.elem(Rank.JNR_DEV.getTag(true, true)) + "s are only permitted to set ranks on test servers!");
return;
}
@ -62,7 +62,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.JNR_DEV || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
{
if (!testServer && rank.Has(Rank.ADMIN) && !Plugin.hasRank(caller, Rank.LT))
if (!testServer && rank.has(Rank.ADMIN) && !Plugin.hasRank(caller, Rank.LT))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Insufficient privileges!"));
return;

View File

@ -56,7 +56,7 @@ public enum Achievement
//Survival Games
SURVIVAL_GAMES_WINS("Katniss Everdeen", 600,
new String[]{"Survival Games.Wins"},
new String[]{"Win 20 games of Survival Games"},
new String[]{"Win 30 games of Survival Games"},
new int[]{30},
AchievementCategory.SURVIVAL_GAMES),
@ -666,7 +666,49 @@ public enum Achievement
new String[]{"Bomb Lobbers.Direct Hit"},
new String[]{"Get 50 direct hits"},
new int[]{50},
AchievementCategory.BOMB_LOBBERS)
AchievementCategory.BOMB_LOBBERS),
EVOLUTION_WINS("Expert Evolver", 1200,
new String[]{"Evolution.Wins"},
new String[]{"Win 20 games of Evolution"},
new int[]{20},
AchievementCategory.EVOLUTION),
EVOLUTION_NO_DEATHS("Perfect Game", 2000,
new String[]{"Evolution.NoDeaths"},
new String[]{"Win a game without dying"},
new int[]{1},
AchievementCategory.EVOLUTION),
EVOLUTION_STEALTH("Stealth Mastah", 1000,
new String[]{"Evolution.Stealth"},
new String[]{"Win without taking any", "damage while evolving"},
new int[]{1},
AchievementCategory.EVOLUTION),
EVOLUTION_RAMPAGE("Rampage", 800,
new String[]{"Evolution.Rampage"},
new String[]{"Get 3 kills within 5 seconds", "of each other"},
new int[]{1},
AchievementCategory.EVOLUTION),
EVOLUTION_MELEE("Melee Monster", 1000,
new String[]{"Evolution.MeleeOnly"},
new String[]{"Win without using any abilities"},
new int[]{1},
AchievementCategory.EVOLUTION),
EVOLUTION_SKILLS("Ability Assassin", 1000,
new String[]{"Evolution.AbilityOnly"},
new String[]{"Win without any melee attacks"},
new int[]{1},
AchievementCategory.EVOLUTION),
EVOLUTION_EVOLVEKILL("No Evolve 5 U", 800,
new String[]{"Evolution.EvolveKill"},
new String[]{"Kill 25 people while they", "Are trying to evolve"},
new int[]{25},
AchievementCategory.EVOLUTION)
;

View File

@ -2,16 +2,18 @@ package mineplex.core.achievement;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime;
import mineplex.core.game.GameDisplay;
import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public enum AchievementCategory
{
GLOBAL("Global", null,
@ -24,11 +26,19 @@ public enum AchievementCategory
Material.IRON_PICKAXE, 0, GameCategory.SURVIVAL, "Destructor Kit"),
SURVIVAL_GAMES("Survival Games", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED,
null, null, new StatDisplay(C.Bold + "Teams Stats", true), null,
StatDisplay.fromGame("Wins", GameDisplay.SurvivalGamesTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SurvivalGamesTeams, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.SurvivalGamesTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SurvivalGamesTeams, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.SurvivalGamesTeams, "GemsEarned") },
Material.DIAMOND_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"),
SKYWARS("Skywars",null,
new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED,
null, null, new StatDisplay(C.Bold + "Team Stats", true), null,
StatDisplay.fromGame("Wins", GameDisplay.SkywarsTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkywarsTeams, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.SkywarsTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkywarsTeams, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.SkywarsTeams, "GemsEarned") },
Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit"),
UHC("Ultra Hardcore", null,
@ -49,7 +59,11 @@ public enum AchievementCategory
Material.GRASS, 0, GameCategory.CLASSICS, "Infestor Kit"),
SMASH_MOBS("Super Smash Mobs", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED,
null, null, new StatDisplay(C.Bold + "Team Stats", true), null,
StatDisplay.fromGame("Wins", GameDisplay.SmashTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SmashTeams, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.SmashTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SmashTeams, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.SmashTeams, "GemsEarned")},
Material.SKULL_ITEM, 4, GameCategory.CLASSICS, "Sheep Kit"),
MINE_STRIKE("MineStrike", null,
@ -123,7 +137,11 @@ public enum AchievementCategory
BOMB_LOBBERS("Bomb Lobbers", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit");
Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit"),
EVOLUTION("Evolution", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
Material.MONSTER_EGG, 0, GameCategory.ARCADE, "Harvester Kit");
private String _name;
private String[] _statsToPull;
@ -199,17 +217,34 @@ public enum AchievementCategory
lore.add(" ");
continue;
}
else if (_statDisplays[i].isJustDisplayName())
{
lore.add(ChatColor.RESET + _statDisplays[i].getDisplayName());
continue;
}
String displayName = _statDisplays[i].getDisplayName();
// Skip showing Losses, Kills, Deaths for other players
if (!clientManager.Get(player).GetRank().Has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
continue;
int statNumber = 0;
for (String statToPull : _statsToPull)
// This is so we could load stats from other games
// (Refer to team games, displaying team stats in the normal game view)
if (_statDisplays[i].isFullStat())
{
for (String statName : _statDisplays[i].getStats())
statNumber += stats.getStat(statToPull + "." + statName);
statNumber += stats.getStat(statName);
}
else
{
for (String statToPull : _statsToPull)
for (String statName : _statDisplays[i].getStats())
statNumber += stats.getStat(statToPull + "." + statName);
}
String statString = C.cWhite + statNumber;
// Need to display special for time
@ -220,8 +255,8 @@ public enum AchievementCategory
}
}
public static enum GameCategory
public enum GameCategory
{
GLOBAL, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE;
GLOBAL, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE
}
}

View File

@ -187,15 +187,15 @@ public class AchievementManager extends MiniPlugin
if (sender.getName().equalsIgnoreCase("B2_mp"))
return 101;
if (rank.Has(Rank.MODERATOR))
if (rank.has(Rank.MODERATOR))
level = Math.max(level, 5);
if (rank.Has(Rank.SNR_MODERATOR))
if (rank.has(Rank.SNR_MODERATOR))
level = Math.max(level, 15);
if (rank.Has(Rank.JNR_DEV))
if (rank.has(Rank.JNR_DEV))
level = Math.max(level, 25);
if (rank.Has(Rank.ADMIN))
if (rank.has(Rank.ADMIN))
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
if (rank.Has(Rank.OWNER))
if (rank.has(Rank.OWNER))
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
if (sender.getName().equalsIgnoreCase("Phinary"))

View File

@ -1,5 +1,7 @@
package mineplex.core.achievement;
import mineplex.core.game.GameDisplay;
/**
* The purpose of extracting stats to this class is so we can display stats that are a combination
* of different stat values. For example, since we don't have a specific stat for games played of a game,
@ -8,19 +10,34 @@ package mineplex.core.achievement;
*/
public class StatDisplay
{
public String _displayName;
public String[] _stats;
private String _displayName;
private String[] _stats;
private boolean _fullStat;
private boolean _justDisplayName;
public StatDisplay(String stat)
{
this(stat, false);
}
public StatDisplay(String stat, boolean justDisplayName)
{
_displayName = stat;
_stats = new String[] { stat };
_fullStat = false;
_justDisplayName = justDisplayName;
}
public StatDisplay(String displayName, String... stats)
{
this(displayName, false, stats);
}
public StatDisplay(String displayName, boolean fullStat, String... stats)
{
_displayName = displayName;
_stats = stats;
_fullStat = fullStat;
}
public String getDisplayName()
@ -28,11 +45,32 @@ public class StatDisplay
return _displayName;
}
public boolean isJustDisplayName()
{
return _justDisplayName;
}
public String[] getStats()
{
return _stats;
}
public boolean isFullStat()
{
return _fullStat;
}
public static StatDisplay fromGame(String name, GameDisplay gameDisplay, String... stats)
{
String[] formattedStats = new String[stats.length];
for (int i = 0; i < stats.length; i++)
{
formattedStats[i] = gameDisplay.getName() + "." + stats[i];
}
return new StatDisplay(name, true, formattedStats);
}
public static final StatDisplay WINS = new StatDisplay("Wins");
public static final StatDisplay LOSSES = new StatDisplay("Losses");
public static final StatDisplay KILLS = new StatDisplay("Kills");

View File

@ -259,7 +259,7 @@ public class AntiHack extends MiniPlugin
//Inform
for (Player admin : UtilServer.getPlayers())
if (_clientManager.Get(admin).GetRank().Has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports)
if (_clientManager.Get(admin).GetRank().has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports)
{
UtilPlayer.message(admin, "#" + total + ": " + C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
}
@ -335,7 +335,7 @@ public class AntiHack extends MiniPlugin
boolean handled = false;
for (Player staff : UtilServer.getPlayers())
{
if (_clientManager.Get(staff).GetRank().Has(Rank.MODERATOR))
if (_clientManager.Get(staff).GetRank().has(Rank.MODERATOR))
{
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cYellow + report);
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cGold + player.getName() + C.cYellow + " has extreme violation. Please investigate.");

View File

@ -132,8 +132,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private int _visualTick;
// Streak
private StreakRecord _dailyStreak;
private StreakRecord _voteStreak;
// private StreakRecord _dailyStreak;
// private StreakRecord _voteStreak;
private ArrayList<String> _voteList;
@ -156,6 +156,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_voteList = new ArrayList<String>();
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
_coinQueue = new LinkedList<GiveDonorData>();
_gemQueue = new LinkedList<GiveDonorData>();
@ -185,6 +186,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_voteList = new ArrayList<String>();
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
_canVote = true;
_coinQueue = new LinkedList<GiveDonorData>();
@ -218,7 +220,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
new VoteHandler(this));
updateOffSet();
updateStreakRecord();
// updateStreakRecord();
}
@Override
@ -238,45 +240,45 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
updateOffSet();
}
@EventHandler
public void updateStreak(UpdateEvent event)
{
if (event.getType() != UpdateType.MIN_16)
return;
updateStreakRecord();
}
private void updateStreakRecord()
{
_repository.getDailyStreakRecord(new Callback<StreakRecord>()
{
@Override
public void run(StreakRecord data)
{
_dailyStreak = data;
}
});
_repository.getVoteStreakRecord(new Callback<StreakRecord>()
{
@Override
public void run(StreakRecord data)
{
_voteStreak = data;
}
});
}
public StreakRecord getDailyStreak()
{
return _dailyStreak;
}
public StreakRecord getVoteStreak()
{
return _voteStreak;
}
// @EventHandler
// public void updateStreak(UpdateEvent event)
// {
// if (event.getType() != UpdateType.MIN_16)
// return;
//
// updateStreakRecord();
// }
//
// private void updateStreakRecord()
// {
// _repository.getDailyStreakRecord(new Callback<StreakRecord>()
// {
// @Override
// public void run(StreakRecord data)
// {
// _dailyStreak = data;
// }
// });
//
// _repository.getVoteStreakRecord(new Callback<StreakRecord>()
// {
// @Override
// public void run(StreakRecord data)
// {
// _voteStreak = data;
// }
// });
// }
//
// public StreakRecord getDailyStreak()
// {
// return _dailyStreak;
// }
//
// public StreakRecord getVoteStreak()
// {
// return _voteStreak;
// }
public void handleVote(final Player player, final int gemsReceived)
{
@ -669,19 +671,19 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
BonusAmount data = new BonusAmount();
if (rank.Has(Rank.MODERATOR))
if (rank.has(Rank.MODERATOR))
{
data.setCoins(35000);
}
if (rank.Has(Rank.LEGEND))
if (rank.has(Rank.LEGEND))
{
data.setCoins(30000);
}
else if (rank.Has(Rank.HERO))
else if (rank.has(Rank.HERO))
{
data.setCoins(15000);
}
else if (rank.Has(Rank.ULTRA))
else if (rank.has(Rank.ULTRA))
{
data.setCoins(7500);
}

View File

@ -160,13 +160,13 @@ public class DailyBonusButton implements GuiItem, Listener
}
}
StreakRecord streakRecord = _bonusManager.getDailyStreak();
if (streakRecord != null)
{
lore.add(" ");
lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
}
// StreakRecord streakRecord = _bonusManager.getDailyStreak();
// if (streakRecord != null)
// {
// lore.add(" ");
// lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
// lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
// }
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);

View File

@ -197,7 +197,7 @@ public class PollButton extends SimpleGui implements GuiItem {
{
_create = true;
_pollManager.answerPoll(getPlayer(), _poll, num);
_pollManager.answerPoll(getPlayer(), _poll, num + 1);
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);

View File

@ -145,13 +145,13 @@ public class VoteButton implements GuiItem, Listener {
lore.add(" ");
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak());
StreakRecord streakRecord = _bonusManager.getVoteStreak();
if (streakRecord != null)
{
lore.add(" ");
lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
}
// StreakRecord streakRecord = _bonusManager.getVoteStreak();
// if (streakRecord != null)
// {
// lore.add(" ");
// lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
// lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
// }
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
}

View File

@ -0,0 +1,164 @@
package mineplex.core.botspam;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.message.PrivateMessageEvent;
import mineplex.core.punish.Category;
import mineplex.core.punish.Punish;
import mineplex.core.botspam.command.BotSpamCommand;
import mineplex.core.botspam.repository.BotSpamRepository;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class BotSpamManager extends MiniPlugin
{
private Punish _punish;
private CoreClientManager _clientManager;
private BotSpamRepository _repository;
private volatile ArrayList<SpamText> _spam = new ArrayList<SpamText>();
public BotSpamManager(JavaPlugin plugin, CoreClientManager clientManager, Punish punish)
{
super("SpamBot Manager", plugin);
_punish = punish;
_clientManager = clientManager;
_repository = new BotSpamRepository(plugin);
_spam = _repository.getSpamText();
}
@EventHandler
public void onPrivateMessage(PrivateMessageEvent event)
{
Player recipient = event.getRecipient();
// Ignore messages sent to staff members
if (_clientManager.hasRank(recipient, Rank.HELPER))
return;
for (SpamText spamText : _spam)
{
if (spamText.isEnabled() && spamText.isSpam(event.getMessage()))
{
punishBot(event.getSender(), spamText);
event.setCancelled(true);
return;
}
}
}
public void punishBot(Player player, final SpamText botText)
{
_punish.AddPunishment(player.getName(), Category.Other, "Bot Spam #" + botText.getId(), "Chiss", 1, true, -1, true);
// Update bot text count
runAsync(new Runnable()
{
@Override
public void run()
{
_repository.addPunishment(botText);
}
});
}
public void addSpamText(final String caller, final String text, final Runnable callback)
{
runAsync(new Runnable()
{
@Override
public void run()
{
_repository.addSpamText(caller, text);
_spam = _repository.getSpamText();
if (callback != null)
runSync(callback);
}
});
}
public void enableSpamText(final String caller, final SpamText spamText, final Runnable callback)
{
runAsync(new Runnable()
{
@Override
public void run()
{
_repository.enableSpamText(caller, spamText);
runSync(new Runnable()
{
@Override
public void run()
{
spamText.setEnabled(true);
spamText.setEnabledBy(caller);
if (callback != null)
callback.run();
}
});
}
});
}
public void disableSpamText(final String caller, final SpamText spamText, final Runnable callback)
{
runAsync(new Runnable()
{
@Override
public void run()
{
_repository.disableSpamText(caller, spamText);
runSync(new Runnable()
{
@Override
public void run()
{
spamText.setEnabled(false);
spamText.setDisabledBy(caller);
if (callback != null)
callback.run();
}
});
}
});
}
public List<SpamText> getSpamTexts()
{
return _spam;
}
@EventHandler
public void updateText(UpdateEvent event)
{
if (event.getType() == UpdateType.MIN_01)
{
runAsync(new Runnable()
{
@Override
public void run()
{
_spam = _repository.getSpamText();
}
});
}
}
@Override
public void addCommands()
{
addCommand(new BotSpamCommand(this));
}
}

View File

@ -0,0 +1,78 @@
package mineplex.core.botspam;
public class SpamText
{
private int _id;
private String _text;
private int _punishments;
private boolean _enabled;
private String _createdBy;
private String _disabledBy;
private String _enabledBy;
public SpamText(int id, String text, int punishments, boolean enabled, String createdBy, String enabledBy, String disabledBy)
{
_id = id;
_text = text;
_punishments = punishments;
_enabled = enabled;
_createdBy = createdBy;
_enabledBy = enabledBy;
_disabledBy = disabledBy;
}
public boolean isSpam(String message)
{
return message.toLowerCase().contains(_text.toLowerCase());
}
public int getId()
{
return _id;
}
public String getText()
{
return _text;
}
public int getPunishments()
{
return _punishments;
}
public boolean isEnabled()
{
return _enabled;
}
public void setEnabled(boolean enabled)
{
_enabled = enabled;
}
public String getCreatedBy()
{
return _createdBy;
}
public String getEnabledBy()
{
return _enabledBy;
}
public String getDisabledBy()
{
return _disabledBy;
}
public void setEnabledBy(String enabledBy)
{
_enabledBy = enabledBy;
}
public void setDisabledBy(String disabledBy)
{
_disabledBy = disabledBy;
}
}

View File

@ -0,0 +1,64 @@
package mineplex.core.botspam.command;
import org.bukkit.entity.Player;
import mineplex.core.botspam.SpamText;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.botspam.BotSpamManager;
public class BotSpamAddCommand extends CommandBase<BotSpamManager>
{
public BotSpamAddCommand(BotSpamManager plugin)
{
super(plugin, Rank.DEVELOPER, "add");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args != null && args.length >= 1)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < args.length; i++)
{
if (i > 0) sb.append(" ");
sb.append(args[i]);
}
final String text = sb.toString();
if (text.length() < 8)
{
UtilPlayer.message(caller, F.main("BotSpam", "Spam text must be at least 8 characters"));
return;
}
for (SpamText spamText : Plugin.getSpamTexts())
{
if (text.equalsIgnoreCase(spamText.getText()))
{
UtilPlayer.message(caller, F.main("BotSpam", "That Spam Text already exists. Type " + F.elem("/botspam list") + " to view"));
return;
}
}
Plugin.addSpamText(caller.getName(), text, new Runnable()
{
@Override
public void run()
{
if (caller.isOnline())
UtilPlayer.message(caller, F.main("BotSpam", "Added Spam Text: " + F.elem(text)));
}
});
}
else
{
UtilPlayer.message(caller, F.main("BotSpam", "/botspam add <text>"));
}
}
}

View File

@ -0,0 +1,31 @@
package mineplex.core.botspam.command;
import org.bukkit.entity.Player;
import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.Rank;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class BotSpamCommand extends MultiCommandBase<BotSpamManager>
{
public BotSpamCommand(BotSpamManager plugin)
{
super(plugin, Rank.DEVELOPER, "botban", "botspam");
AddCommand(new BotSpamAddCommand(Plugin));
AddCommand(new BotSpamEnableCommand(Plugin));
AddCommand(new BotSpamDisableCommand(Plugin));
AddCommand(new BotSpamListCommand(Plugin));
}
@Override
protected void Help(Player caller, String[] args)
{
UtilPlayer.message(caller, F.main("BotSpam", "/botspam list"));
UtilPlayer.message(caller, F.main("BotSpam", "/botspam add <text>"));
UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable <text id>"));
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
}
}

View File

@ -0,0 +1,71 @@
package mineplex.core.botspam.command;
import org.bukkit.entity.Player;
import mineplex.core.botspam.SpamText;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class BotSpamDisableCommand extends CommandBase<BotSpamManager>
{
public BotSpamDisableCommand(BotSpamManager plugin)
{
super(plugin, Rank.DEVELOPER, "disable");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args != null && args.length == 1)
{
final int spamId;
try
{
spamId = Integer.parseInt(args[0]);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
return;
}
SpamText text = null;
for (SpamText spamText : Plugin.getSpamTexts())
{
if (spamText.getId() == spamId)
text = spamText;
}
if (text == null)
{
UtilPlayer.message(caller, F.main("BotSpam", "Could not find a spam text with the id " + F.elem("" + spamId)));
return;
}
if (!text.isEnabled())
{
UtilPlayer.message(caller, F.main("BotSpam", "That spam text is already disabled"));
return;
}
final SpamText finalText = text;
Plugin.disableSpamText(caller.getName(), text, new Runnable()
{
@Override
public void run()
{
UtilPlayer.message(caller, F.main("BotSpam", "Disabled Spam Text " + F.elem(finalText.getText())));
}
});
}
else
{
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
}
}
}

View File

@ -0,0 +1,71 @@
package mineplex.core.botspam.command;
import org.bukkit.entity.Player;
import mineplex.core.botspam.SpamText;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class BotSpamEnableCommand extends CommandBase<BotSpamManager>
{
public BotSpamEnableCommand(BotSpamManager plugin)
{
super(plugin, Rank.DEVELOPER, "enable");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args != null && args.length == 1)
{
final int spamId;
try
{
spamId = Integer.parseInt(args[0]);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable <text id>"));
return;
}
SpamText text = null;
for (SpamText spamText : Plugin.getSpamTexts())
{
if (spamText.getId() == spamId)
text = spamText;
}
if (text == null)
{
UtilPlayer.message(caller, F.main("BotSpam", "Could not find a spam text with the id " + F.elem("" + spamId)));
return;
}
if (text.isEnabled())
{
UtilPlayer.message(caller, F.main("BotSpam", "That spam text is already enabled"));
return;
}
final SpamText finalText = text;
Plugin.enableSpamText(caller.getName(), text, new Runnable()
{
@Override
public void run()
{
UtilPlayer.message(caller, F.main("BotSpam", "Enabled Spam Text " + F.elem(finalText.getText())));
}
});
}
else
{
UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable <text id>"));
}
}
}

View File

@ -0,0 +1,46 @@
package mineplex.core.botspam.command;
import org.bukkit.entity.Player;
import mineplex.core.botspam.SpamText;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.HoverEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class BotSpamListCommand extends CommandBase<BotSpamManager>
{
public BotSpamListCommand(BotSpamManager plugin)
{
super(plugin, Rank.DEVELOPER, "list");
}
@Override
public void Execute(Player caller, String[] args)
{
UtilPlayer.message(caller, F.main("BotSpam", "Listing Spam Texts. Hover for more details"));
UtilPlayer.message(caller, ""); // Blank Line!
for (SpamText spamText : Plugin.getSpamTexts())
{
String modifyMessage = spamText.isEnabled() ? C.cRed + "Click To Disable" : C.cGreen + "Click To Enable";
String hoverMessage = C.cYellow + "Spam Id: " + C.cWhite + spamText.getId() + "\\n" + C.cYellow + "Ban Count: " + C.cWhite + spamText.getPunishments() + "\\n" + C.cYellow + "Enabled: " + C.cWhite + spamText.isEnabled();
hoverMessage += "\\n\\n" + C.cYellow + "Created By: " + C.cWhite + spamText.getCreatedBy();
if (spamText.getEnabledBy() != null)
hoverMessage += "\\n" + C.cYellow + "Enabled By: " + C.cWhite + spamText.getEnabledBy();
if (spamText.getDisabledBy() != null)
hoverMessage += "\\n" + C.cYellow + "Disabled By: " + C.cWhite + spamText.getDisabledBy();
hoverMessage += "\\n\\n" + modifyMessage;
JsonMessage message = new JsonMessage((spamText.isEnabled() ? "" : C.cRed) + spamText.getText());
message.hover(HoverEvent.SHOW_TEXT, hoverMessage);
message.click(ClickEvent.RUN_COMMAND, "/botspam " + (spamText.isEnabled() ? "disable" : "enable") + " " + spamText.getId());
message.send(JsonMessage.MessageType.SYSTEM_MESSAGE, caller);
}
}
}

View File

@ -0,0 +1,88 @@
package mineplex.core.botspam.repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.botspam.SpamText;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnVarChar;
public class BotSpamRepository extends RepositoryBase
{
private static final String GET_SPAM_TEXT = "SELECT * FROM botSpam";
private static final String ADD_SPAM_TEXT = "INSERT INTO botSpam (text, createdBy, enabledBy) VALUES (?, ?, ?)";
private static final String DELETE_SPAM_TEXT = "DELETE FROM botSpam WHERE id = ?";
private static final String ENABLE_SPAM_TEXT = "UPDATE botSpam SET enabled = 1, enabledBy = ? WHERE id = ?";
private static final String DISABLE_SPAM_TEXT = "UPDATE botSpam SET enabled = 0 AND disabledBy = ? WHERE id = ?";
private static final String ADD_PUNISHMENT = "UPDATE botSpam SET punishments = punishments + 1 WHERE id = ?";
public BotSpamRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
}
public ArrayList<SpamText> getSpamText()
{
final ArrayList<SpamText> list = new ArrayList<SpamText>();
executeQuery(GET_SPAM_TEXT, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
int id = resultSet.getInt(1);
String text = resultSet.getString(2);
int punishments = resultSet.getInt(3);
boolean enabled = resultSet.getBoolean(4);
String createdBy = resultSet.getString(5);
String enabledBy = resultSet.getString(6);
String disabledBy = resultSet.getString(7);
list.add(new SpamText(id, text, punishments, enabled, createdBy, enabledBy, disabledBy));
}
}
});
return list;
}
public void addPunishment(SpamText text)
{
executeUpdate(ADD_PUNISHMENT, new ColumnInt("id", text.getId()));
}
public void disableSpamText(String caller, SpamText text)
{
executeUpdate(DISABLE_SPAM_TEXT, new ColumnVarChar("disabledBy", 100, caller), new ColumnInt("id", text.getId()));
}
public void enableSpamText(String caller, SpamText text)
{
executeUpdate(ENABLE_SPAM_TEXT, new ColumnVarChar("enabledBy", 100, caller), new ColumnInt("id", text.getId()));
}
public void addSpamText(String caller, String spamText)
{
executeInsert(ADD_SPAM_TEXT, null, new ColumnVarChar("text", 200, spamText), new ColumnVarChar("createdBy", 100, caller), new ColumnVarChar("enabledBy", 100, caller));
}
@Override
protected void initialize()
{
}
@Override
protected void update()
{
}
}

View File

@ -176,7 +176,7 @@ public class Chat extends MiniPlugin
if (_silenced == 0)
return false;
if (_clientManager.Get(player).GetRank().Has(player, Rank.MODERATOR, false))
if (_clientManager.Get(player).GetRank().has(player, Rank.MODERATOR, false))
return false;
if (_silenced == -1)
@ -210,7 +210,7 @@ public class Chat extends MiniPlugin
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSignChange(SignChangeEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN)) return;
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) return;
// Prevent silenced players from using signs
if (SilenceCheck(event.getPlayer()))
@ -317,13 +317,13 @@ public class Chat extends MiniPlugin
UtilPlayer.message(sender, C.cYellow + "Buy a Rank at " + C.cGreen + "www.mineplex.com/shop" + C.cYellow + " to remove this limit!");
event.setCancelled(true);
}
else if (!_clientManager.Get(sender).GetRank().Has(Rank.MODERATOR) &&
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
!Recharge.Instance.use(sender, "Chat Message", 400, false, false))
{
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
event.setCancelled(true);
}
else if (!_clientManager.Get(sender).GetRank().Has(Rank.HELPER) &&
else if (!_clientManager.Get(sender).GetRank().has(Rank.HELPER) &&
msgContainsHack(event.getMessage()))
{
UtilPlayer.message(sender, F.main("Chat",
@ -337,12 +337,12 @@ public class Chat extends MiniPlugin
MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId());
long chatSlowTime = 1000L * _chatSlow;
long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().Has(Rank.HELPER))
if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().has(Rank.HELPER))
{
UtilPlayer.message(sender, F.main("Chat", "Chat slow enabled. Please wait " + F.time(UtilTime.convertString(chatSlowTime - timeDiff, 1, UtilTime.TimeUnit.FIT))));
event.setCancelled(true);
}
else if (!_clientManager.Get(sender).GetRank().Has(Rank.MODERATOR) &&
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
UtilText.isStringSimilar(event.getMessage(), lastMessage.getMessage(), 0.8f))
{
UtilPlayer.message(sender, F.main("Chat", "This message is too similar to your previous message."));

View File

@ -62,7 +62,7 @@ public class CommandCenter implements Listener
{
event.setCancelled(true);
if (ClientManager.Get(event.getPlayer()).GetRank().Has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true))
if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true))
{
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
{
@ -76,19 +76,6 @@ public class CommandCenter implements Listener
}
}
@EventHandler
public void onTabComplete(TabCompleteEvent event)
{
ICommand command = Commands.get(event.getCommand().toLowerCase());
if (command != null)
{
List<String> suggestions = command.onTabComplete(event.getSender(), event.getCommand(), event.getArgs());
if (suggestions != null)
event.setSuggestions(suggestions);
}
}
public void AddCommand(ICommand command)
{

View File

@ -59,7 +59,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
ICommand command = Commands.get(commandName);
if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().Has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
{
command.SetAliasUsed(commandName);

View File

@ -75,7 +75,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (pet.GetPetType() == EntityType.WITHER)
{
itemLore.add(C.cBlack);
itemLore.add(ChatColor.RESET + C.cYellow + "Unlocked with Legend Rank");
itemLore.add(ChatColor.RESET + C.cGreen + "Unlocked with Legend Rank");
}
}

View File

@ -30,9 +30,9 @@ public abstract class DisguiseInsentient extends DisguiseLiving
{
if (rank != null)
{
if (rank.Has(Rank.ULTRA))
if (rank.has(Rank.ULTRA))
{
name = rank.GetTag(true, true) + " " + ChatColor.RESET + name;
name = rank.getTag(true, true) + " " + ChatColor.RESET + name;
}
}

View File

@ -24,6 +24,7 @@ import mineplex.core.donation.repository.token.DonorTokenWrapper;
import mineplex.core.server.util.TransactionResponse;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.playerCache.PlayerCache;
public class DonationManager extends MiniDbClientPlugin<Donor>
{
@ -279,7 +280,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
{
public void run()
{
RewardCoins(null, caller, player.getName(), ClientManager.getCachedClientAccountId(player.getUniqueId()), total, false);
RewardCoins(null, caller, player.getName(), PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(), total, false);
}
});
}

View File

@ -251,7 +251,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
public void showFriends(Player caller)
{
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
boolean isStaff = ClientManager.Get(caller).GetRank().has(Rank.HELPER);
boolean gotAFriend = false;
List<FriendStatus> friendStatuses = Get(caller).getFriends();
Collections.sort(friendStatuses, _friendSorter);

View File

@ -166,11 +166,11 @@ public class GadgetManager extends MiniPlugin
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR))
{
for (GadgetType gadgetType : _gadgets.keySet())
{
if (gadgetType == GadgetType.Particle && _clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN))
if (gadgetType == GadgetType.Particle && _clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN))
{
for (Gadget gadget : _gadgets.get(gadgetType))
{
@ -455,12 +455,16 @@ public class GadgetManager extends MiniPlugin
@EventHandler
public void chissMeow(PlayerToggleSneakEvent event)
{
if (event.getPlayer().getName().equals("Chiss"))
{
if (!event.getPlayer().isSneaking())
{
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f);
}
}
if (event.getPlayer().isSneaking())
return;
if (event.getPlayer().getName().equalsIgnoreCase("Chiss"))
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f);
if (event.getPlayer().getName().equalsIgnoreCase("defek7"))
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.WOLF_BARK, 1f, 1f);
if (event.getPlayer().getName().equalsIgnoreCase("sterling_"))
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.PIG_IDLE, 1f, 1f);
}
}

View File

@ -82,7 +82,7 @@ public class MorphBlaze extends MorphGadget
@EventHandler
public void HeroOwner(PlayerJoinEvent event)
{
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO))
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}

View File

@ -59,8 +59,7 @@ public class MorphBunny extends MorphGadget
" ",
C.cRed +C.Bold + "WARNING: " + ChatColor.RESET + "Hide Easter Egg uses 500 Coins" ,
" ",
C.cPurple + "Special Limited Time Morph",
C.cPurple + "Purchase at www.mineplex.com/shop",
C.cPurple + "No longer available",
},
-1,
Material.MONSTER_EGG, (byte)98);

View File

@ -170,7 +170,7 @@ public class MorphCreeper extends MorphGadget
@EventHandler
public void HeroOwner(PlayerJoinEvent event)
{
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO))
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}

View File

@ -38,7 +38,7 @@ public class MorphPig extends MorphGadget
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Oink",
C.cYellow + "Collide" + C.cGray + " to use " + C.cGreen + "Pig Bounce",
" ",
C.cPurple + "Unlocked with Ultra Rank",
C.cAqua + "Unlocked with Ultra Rank",
},
-1,
Material.PORK, (byte)0);
@ -83,7 +83,7 @@ public class MorphPig extends MorphGadget
@EventHandler
public void HeroOwner(PlayerJoinEvent event)
{
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.ULTRA))
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.ULTRA))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}

View File

@ -47,7 +47,7 @@ public class MorphWither extends MorphGadget
" ",
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Wither Skull",
" ",
C.cPurple + "Unlocked with Legend Rank",
C.cGreen + "Unlocked with Legend Rank",
},
-1,
Material.SKULL_ITEM, (byte)1);
@ -177,10 +177,7 @@ public class MorphWither extends MorphGadget
@EventHandler
public void legendOwner(PlayerJoinEvent event)
{
if (Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.LEGEND ||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.ADMIN ||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.DEVELOPER ||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.OWNER)
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}

View File

@ -22,7 +22,7 @@ public class ParticleLegend extends ParticleGadget
C.cWhite + "These mystic particle attach to",
C.cWhite + "only the most legendary of players!",
" ",
C.cPurple + "Unlocked with Legend Rank",
C.cGreen + "Unlocked with Legend Rank",
},
-2,
Material.ENDER_PORTAL, (byte)0);
@ -46,7 +46,7 @@ public class ParticleLegend extends ParticleGadget
@EventHandler
public void legendOwner(PlayerJoinEvent event)
{
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.LEGEND))
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}

View File

@ -151,21 +151,47 @@ public class LoadingWindow implements Runnable, Listener {
{
Player player = Bukkit.getPlayer(_playersUUID);
if (player == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (_inv != null && !player.getOpenInventory().getTopInventory().equals(_inv))) {
end();
return;
}
if (_inv == null) {
_inv = Bukkit.createInventory(null, _size, _title);
try
{
if (player == null || player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (!player.getOpenInventory().getTopInventory().equals(_inv)))
{
end();
return;
}
setBackGround();
setLoadingBarItems();
UtilPlayer.swapToInventory(player, _inv);
Bukkit.getPluginManager().registerEvents(this, _plugin);
} else
setLoadingBarItems();
_ticker++;
if (_inv == null)
{
_inv = Bukkit.createInventory(null, _size, _title);
setBackGround();
setLoadingBarItems();
UtilPlayer.swapToInventory(player, _inv);
Bukkit.getPluginManager().registerEvents(this, _plugin);
}
else
setLoadingBarItems();
}
catch (Exception exception)
{
try
{
System.out.println("player ? " + (player == null));
System.out.println("player.getOpenInventory() ? " + (player.getOpenInventory() == null));
System.out.println("player.getOpenInventory().getTopInventory() ? " + (player.getOpenInventory().getTopInventory() == null));
System.out.println("_inv ? " + (_inv == null));
exception.printStackTrace();
}
catch (Exception exception2)
{
exception.printStackTrace();
}
end();
}
finally
{
_ticker++;
}
}
public void end() {

View File

@ -88,7 +88,7 @@ public class IgnoreManager extends MiniDbClientPlugin<IgnoreData>
@EventHandler
public void onChat(AsyncPlayerChatEvent event)
{
if (ClientManager.Get(event.getPlayer()).GetRank().Has(Rank.HELPER))
if (ClientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER))
return;
Iterator<Player> itel = event.getRecipients().iterator();

View File

@ -21,6 +21,7 @@ import mineplex.core.inventory.data.InventoryRepository;
import mineplex.core.inventory.data.Item;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.playerCache.PlayerCache;
public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
{
@ -180,7 +181,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
synchronized (_inventoryLock)
{
final boolean success = _repository.incrementClientInventoryItem(ClientManager.getCachedClientAccountId(uuid), _items.get(item).Id, count);
final boolean success = _repository.incrementClientInventoryItem(PlayerCache.getInstance().getPlayer(uuid).getAccountId(), _items.get(item).Id, count);
if (callback != null)
{

View File

@ -308,9 +308,10 @@ public class ItemBuilder
return this;
}
public void setData(short newData)
public ItemBuilder setData(short newData)
{
this._data = newData;
return this;
}
public ItemBuilder setPotion(Potion potion)

View File

@ -191,7 +191,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
// My attempt at trying to mitigate some of the spam bots - Phinary
// Triggers if they are whispering a new player
if (!GetClientManager().Get(from).GetRank().Has(Rank.HELPER) && Get(from).LastTo != null
if (!GetClientManager().Get(from).GetRank().has(Rank.HELPER) && Get(from).LastTo != null
&& !Get(from).LastTo.equalsIgnoreCase(to.getName()))
{
long delta = System.currentTimeMillis() - Get(from).LastToTime;
@ -252,7 +252,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
{
if (!to.equals(staff) && !from.equals(staff))
{
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
if (_clientManager.Get(staff).GetRank().has(Rank.HELPER))
{
UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + C.cPurple
+ " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + message);
@ -369,7 +369,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
{
if (!to.equals(staff))
{
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
if (_clientManager.Get(staff).GetRank().has(Rank.HELPER))
{
UtilPlayer.message(staff,
@ -447,7 +447,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
{
if (!target.equals(staff))
{
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
if (_clientManager.Get(staff).GetRank().has(Rank.HELPER))
{
UtilPlayer.message(staff,

View File

@ -48,7 +48,7 @@ public class AdminCommand extends CommandBase<MessageManager>
boolean staff = false;
for (Player to : UtilServer.getPlayers())
{
if (Plugin.GetClientManager().Get(to).GetRank().Has(Rank.HELPER))
if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER))
{
if (!to.equals(caller))
UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message);

View File

@ -24,7 +24,7 @@ public class MessageAdminCommand extends CommandBase<MessageManager>
}
else
{
if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true))
if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true))
return;
if (args.length == 0)

View File

@ -24,7 +24,7 @@ public class ResendAdminCommand extends CommandBase<MessageManager>
}
else
{
if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true))
if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true))
return;
String lastTo = Plugin.Get(caller).LastAdminTo;

View File

@ -9,7 +9,9 @@ import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -25,9 +27,14 @@ public class LagMeter extends MiniPlugin
private double _ticksPerSecond;
private double _ticksPerSecondAverage;
private long _lastAverage;
private long _start;
private long _lastTick = 0;
private boolean _timingsRunning;
private boolean _timingsPasted;
private long _timingsStarted;
private HashSet<Player> _monitoring = new HashSet<Player>();
public LagMeter(JavaPlugin plugin, CoreClientManager clientManager)
@ -37,12 +44,14 @@ public class LagMeter extends MiniPlugin
_clientManager = clientManager;
_lastRun = System.currentTimeMillis();
_lastAverage = System.currentTimeMillis();
_start = System.currentTimeMillis();
}
@EventHandler
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR))
{
if (event.getMessage().trim().equalsIgnoreCase("/lag"))
{
@ -87,6 +96,24 @@ public class LagMeter extends MiniPlugin
_lastRun = now;
_count++;
if (System.currentTimeMillis() - _start > 60000)
{
if (_timingsRunning)
{
if (_ticksPerSecond > 15 || System.currentTimeMillis() - _timingsStarted > 60000)
{
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings paste");
_timingsRunning = false;
}
}
else if (_ticksPerSecond < 10)
{
_timingsRunning = true;
_timingsStarted = System.currentTimeMillis();
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings on");
}
}
}
public double getTicksPerSecond()

View File

@ -110,7 +110,7 @@ public class MountDragon extends DragonMount
@EventHandler
public void HeroOwner(PlayerJoinEvent event)
{
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO))
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}

View File

@ -22,12 +22,12 @@ public class NotificationManager extends MiniPlugin
private CoreClientManager _clientManager;
private String _summerLine =
C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" +
C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" +
C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" +
C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" +
C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" +
C.cYellow + "" + C.cGold + "" + C.cYellow + "" + C.cGold + "" + C.cYellow + "";
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" +
C.cYellow + "" + C.cBlack + "" + C.cYellow + "" + C.cBlack + "" + C.cYellow + "";
public NotificationManager(JavaPlugin plugin, CoreClientManager client)
{
@ -45,8 +45,8 @@ public class NotificationManager extends MiniPlugin
// if (event.getType() == UpdateType.MIN_08)
// hugeSale();
// if (event.getType() == UpdateType.MIN_16)
// sale();
if (event.getType() == UpdateType.MIN_16)
sale();
}
private void sale()
@ -55,23 +55,23 @@ public class NotificationManager extends MiniPlugin
{
Rank rank = _clientManager.Get(player).GetRank();
if (rank.Has(Rank.LEGEND))
if (rank.has(Rank.LEGEND))
continue;
if (rank == Rank.ALL)
{
UtilPlayer.message(player, C.cWhite + "Summer Sale! " + " Purchase " + C.cAqua + C.Bold + "Ultra RANK" + C.cWhite + " for $15");
UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + " Purchase " + C.cAqua + C.Bold + "Ultra Rank" + C.cWhite + " for $15");
}
else if (rank == Rank.ULTRA)
{
UtilPlayer.message(player, C.cWhite + "Summer Sale! " + " Upgrade to " + C.cPurple + C.Bold + "HERO RANK" + C.cWhite + " for $15!");
UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + " Upgrade to " + C.cPurple + C.Bold + "Hero Rank" + C.cWhite + " for $15!");
}
else if (rank == Rank.HERO)
{
UtilPlayer.message(player, C.cWhite + "Summer Sale! " + "Upgrade to " + C.cGreen + C.Bold + "LEGEND RANK" + C.cWhite + " for $15!");
UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + "Upgrade to " + C.cGreen + C.Bold + "Legend Rank" + C.cWhite + " for $15!");
}
UtilPlayer.message(player, C.cWhite + " Visit " + F.link("www.mineplex.com/shop") + " for 50% Off Ranks!");
UtilPlayer.message(player, C.cWhite + " Visit " + F.link("www.mineplex.com/shop") + C.cWhite + " for 50% Off Ranks!");
}
}
@ -81,7 +81,7 @@ public class NotificationManager extends MiniPlugin
{
Rank rank = _clientManager.Get(player).GetRank();
if (rank.Has(Rank.LEGEND))
if (rank.has(Rank.LEGEND))
continue;
UtilPlayer.message(player, _summerLine);

View File

@ -48,6 +48,17 @@ public class PacketHandler extends MiniPlugin
EnumProtocol.PLAY.a().put(2, PacketPlayUseEntity.class);
EnumProtocol.PLAY.a().put(PacketPlayUseEntity.class, 2);
// NBT Overflow Exploit Handlers
EnumProtocol.PLAY.a().put(8, PacketPlayInBlockPace.class);
EnumProtocol.PLAY.a().put(PacketPlayInBlockPace.class, 8);
EnumProtocol.PLAY.a().put(14, PacketPlayInWindowClick.class);
EnumProtocol.PLAY.a().put(PacketPlayInWindowClick.class, 14);
EnumProtocol.PLAY.a().put(16, PacketPlayInSetCreativeSlot.class);
EnumProtocol.PLAY.a().put(PacketPlayInSetCreativeSlot.class, 16);
// ----------------------------
Method method = ProtocolInjector.class.getDeclaredMethod("addPacket", EnumProtocol.class,boolean.class, int.class, Class.class);
method.setAccessible(true);

View File

@ -0,0 +1,15 @@
package mineplex.core.packethandler;
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
import net.minecraft.server.v1_7_R4.PacketPlayInBlockPlace;
public class PacketPlayInBlockPace extends PacketPlayInBlockPlace
{
@Override
public void a(PacketDataSerializer data)
{
super.a(WrappedPacketDataSerializer.wrapDataSerializer(data));
}
}

View File

@ -0,0 +1,15 @@
package mineplex.core.packethandler;
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
public class PacketPlayInSetCreativeSlot extends net.minecraft.server.v1_7_R4.PacketPlayInSetCreativeSlot
{
@Override
public void a(PacketDataSerializer data)
{
super.a(WrappedPacketDataSerializer.wrapDataSerializer(data));
}
}

View File

@ -0,0 +1,14 @@
package mineplex.core.packethandler;
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
public class PacketPlayInWindowClick extends net.minecraft.server.v1_7_R4.PacketPlayInWindowClick
{
@Override
public void a(PacketDataSerializer data)
{
super.a(WrappedPacketDataSerializer.wrapDataSerializer(data));
}
}

View File

@ -0,0 +1,85 @@
package mineplex.core.packethandler;
import java.io.DataInputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.spigotmc.LimitStream;
import net.minecraft.server.v1_7_R4.Item;
import net.minecraft.server.v1_7_R4.ItemStack;
import net.minecraft.server.v1_7_R4.NBTCompressedStreamTools;
import net.minecraft.server.v1_7_R4.NBTReadLimiter;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
import net.minecraft.util.io.netty.buffer.ByteBuf;
import net.minecraft.util.io.netty.buffer.ByteBufInputStream;
public class WrappedPacketDataSerializer extends PacketDataSerializer
{
public WrappedPacketDataSerializer(ByteBuf bytebuf)
{
super(bytebuf);
}
public WrappedPacketDataSerializer(ByteBuf bytebuf, int version)
{
super(bytebuf, version);
}
@Override
public ItemStack c()
{
try {
ItemStack itemstack = null;
short short0 = readShort();
if (short0 >= 0)
{
byte b0 = readByte();
short short1 = readShort();
itemstack = new ItemStack(Item.getById(short0), b0, short1);
itemstack.setTag(b());
if (itemstack.getTag() != null) {
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
}
}
return itemstack;
} catch (Exception e) {
this.clear();
return null;
}
}
@Override
public NBTTagCompound b()
{
int i = readerIndex();
byte b0 = readByte();
if (b0 == 0) {
return null;
}
readerIndex(i);
ByteBufInputStream data = new ByteBufInputStream(this);
NBTReadLimiter nbtreadlimiter = new NBTReadLimiter(2097152L);
return NBTCompressedStreamTools.a(new DataInputStream(new LimitStream((InputStream)data, nbtreadlimiter)), nbtreadlimiter);
}
public static WrappedPacketDataSerializer wrapDataSerializer(PacketDataSerializer data) {
try
{
Field a = data.getClass().getDeclaredField("a");
a.setAccessible(true);
ByteBuf buff = (ByteBuf) a.get(data);
WrappedPacketDataSerializer w = new WrappedPacketDataSerializer(buff, data.version);
return w;
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
}

View File

@ -82,7 +82,7 @@ public class Party
for (Rank rank : Rank.values())
{
if (rank != Rank.ALL)
_scoreboard.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, false) + ChatColor.RESET + " ");
_scoreboard.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, false) + ChatColor.RESET + " ");
else
_scoreboard.registerNewTeam(rank.Name).setPrefix("");
}

View File

@ -70,7 +70,7 @@ public class PersonalServerManager extends MiniPlugin
if (!Recharge.Instance.use(event.getPlayer(), "Host Server Melon", 30000, false, false))
return;
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.LEGEND))
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.LEGEND))
{
showHostMessage(event.getPlayer());
}
@ -124,7 +124,7 @@ public class PersonalServerManager extends MiniPlugin
Rank rank = _clientManager.Get(player).GetRank();
if (eventServer || rank.Has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)
if (eventServer || rank.has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)
{
ram = 2048;
cpu = 4;

View File

@ -146,7 +146,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
{
Player p = event.getPlayer();
Rank rank = _clientManager.Get(p).GetRank();
if (rank == Rank.LEGEND || rank == Rank.ADMIN || rank == Rank.DEVELOPER || rank == Rank.OWNER)
if (rank.has(Rank.LEGEND))
{
_donationManager.Get(p.getName()).AddUnknownSalesPackagesOwned("Widder");
}
@ -228,8 +228,14 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (_activePetOwners.containsKey(player.getName()))
{
final Creature pet = _activePetOwners.get(player.getName());
//Wither Silverfish
if (pet.getPassenger() != null)
pet.getPassenger().remove();
pet.remove();
if (removeOwner)
{
_activePetOwners.remove(player.getName());

View File

@ -13,9 +13,9 @@ public enum DisplayType
switch (this)
{
case RANKED:
return rank.Has(Rank.ULTRA);
return rank.has(Rank.ULTRA);
case NOT_RANKED:
return !rank.Has(Rank.ULTRA);
return !rank.has(Rank.ULTRA);
default:
return true;
}

View File

@ -39,7 +39,7 @@ public class PollCommand extends CommandBase<PollManager>
return;
}
if (args[0].equalsIgnoreCase("list") && CommandCenter.GetClientManager().Get(caller).GetRank().Has(Rank.MODERATOR))
if (args[0].equalsIgnoreCase("list") && CommandCenter.GetClientManager().Get(caller).GetRank().has(Rank.MODERATOR))
{
if (args.length == 1)
{

View File

@ -43,7 +43,7 @@ public class ServerCommand extends CommandBase<Portal>
Plugin.doesServerExist(args[0], new Callback<Boolean>()
{
public void run(final Boolean serverExists)
{
{
if (!serverExists)
{
UtilPlayer.message(
@ -58,32 +58,45 @@ public class ServerCommand extends CommandBase<Portal>
if (servUp.contains("HERO"))
{
if (playerRank.Has(Rank.HERO))
if (playerRank.has(Rank.HERO))
Plugin.sendPlayerToServer(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("ULTRA") || servUp.contains("BETA"))
{
if (playerRank.Has(Rank.ULTRA))
if (playerRank.has(Rank.ULTRA))
Plugin.sendPlayerToServer(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("STAFF"))
{
if (playerRank.Has(Rank.HELPER))
if (playerRank.has(Rank.HELPER))
Plugin.sendPlayerToServer(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("TEST"))
{
if (playerRank.Has(Rank.MODERATOR))
if (playerRank.has(Rank.MODERATOR))
Plugin.sendPlayerToServer(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("CLANS-"))
{
if (playerRank.has(Rank.MODERATOR))
{
Plugin.sendPlayerToServer(player, args[0]);
}
else
{
UtilPlayer.message(player,
F.main(Plugin.getName(), C.cRed + "You must join clans through the hub! Join " + C.cGold + "ClansHub-1"
+ C.cRed + "!"));
}
}
else
{
Plugin.sendPlayerToServer(player, args[0]);

View File

@ -116,7 +116,7 @@ public class Portal extends MiniPlugin
{
public void run()
{
if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.Has(Rank.ULTRA))
if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA))
{
sendPlayer(player, serverName);
}

View File

@ -165,7 +165,19 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
protected void toggleHubInvisibility(org.bukkit.entity.Player player)
{
getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility;
_hubInvisibilityToggled = !_hubInvisibilityToggled;
//Dont save for Mod/SnrMod - prevents them just being invis 24/7
if (getPlugin().Get(player).Invisibility)
{
if (getClient().GetRank().has(Rank.ADMIN) ||
getClient().GetRank() == Rank.YOUTUBE ||
getClient().GetRank() == Rank.YOUTUBE_SMALL ||
getClient().GetRank() == Rank.TWITCH)
{
_hubInvisibilityToggled = !_hubInvisibilityToggled;
}
}
buildPage();
}
@ -243,7 +255,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
UserPreferences userPreferences = getPlugin().Get(getPlayer());
int index = 9;
buildPreference(index, Material.FIREBALL, "Hub Stacker", userPreferences.HubGames, _toggleHubGames);
buildPreference(index, Material.FIREBALL, "Hub Player Stacker", userPreferences.HubGames, _toggleHubGames);
index += 2;
buildPreference(index, Material.EYE_OF_ENDER, "Hub Player Visibility", userPreferences.ShowPlayers, _toggleHubPlayers);
index += 2;
@ -254,24 +266,25 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
buildPreference(index, Material.SKULL_ITEM, (byte)3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests);
buildPreference(40, Material.RED_ROSE, "Show Pending Friend Requests", userPreferences.PendingFriendRequests, _togglePendingFriendRequests);
if (getClientManager().Get(getPlayer()).GetRank() == Rank.YOUTUBE || getClientManager().Get(getPlayer()).GetRank() == Rank.TWITCH)
{
buildPreference(38, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
buildPreference(42, Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
buildPreference(44, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
}
if (getClientManager().Get(getPlayer()).GetRank().Has(Rank.ADMIN) || getClientManager().Get(getPlayer()).GetRank() == Rank.JNR_DEV)
if (getClientManager().Get(getPlayer()).GetRank().has(Rank.ADMIN) || getClientManager().Get(getPlayer()).GetRank() == Rank.JNR_DEV)
{
buildPreference(36, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
buildPreference(38, Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
buildPreference(42, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
buildPreference(44, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
}
else if (getClientManager().Get(getPlayer()).GetRank().Has(Rank.MODERATOR))
else if (getClientManager().Get(getPlayer()).GetRank().has(Rank.MODERATOR))
{
buildPreference(38, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
buildPreference(42, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
buildPreference(38, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
buildPreference(42, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
buildPreference(44, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
}
else if (getClientManager().Get(getPlayer()).GetRank() == Rank.YOUTUBE || getClientManager().Get(getPlayer()).GetRank() == Rank.TWITCH)
{
buildPreference(38, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
buildPreference(42, Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
buildPreference(44, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
}
}

View File

@ -113,24 +113,30 @@ public class Punish extends MiniPlugin
UtilPlayer.message(caller, F.main(_moduleName, "Commands List:"));
UtilPlayer.message(caller, F.help("/punish", "<player> <reason>", Rank.MODERATOR));
}
public void AddPunishment(final String playerName, final Category category, final String reason, final Player caller, final int severity, boolean ban, long duration)
{
AddPunishment(playerName, category, reason, caller == null ? null : caller.getName(), severity, ban, duration, false);
}
public void AddPunishment(final String playerName, final Category category, final String reason, final String callerName, final int severity, boolean ban, long duration, final boolean silent)
{
if (!_punishClients.containsKey(playerName.toLowerCase()))
{
_punishClients.put(playerName.toLowerCase(), new PunishClient());
}
final Player caller = (callerName == null ? null : UtilPlayer.searchExact(callerName));
final PunishmentSentence sentence = !ban ? PunishmentSentence.Mute : PunishmentSentence.Ban;
final long finalDuration = duration;
_repository.Punish(new Callback<String>()
{
public void run(String result)
{
PunishmentResponse banResult = PunishmentResponse.valueOf(result);
if (banResult == PunishmentResponse.AccountDoesNotExist)
{
if (caller != null)
@ -159,10 +165,9 @@ public class Punish extends MiniPlugin
public void run()
{
String kickReason = C.cRed + C.Bold + "You were banned for " + durationString + " by " + (caller == null ? "Mineplex Anti-Cheat" : caller.getName()) +
"\n" + C.cWhite + reason +
"\n" + C.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals"
;
"\n" + C.cWhite + reason +
"\n" + C.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals";
Player target = UtilPlayer.searchOnline(null, playerName, false);
if (target != null)
target.kickPlayer(kickReason);
@ -170,8 +175,11 @@ public class Punish extends MiniPlugin
new mineplex.serverdata.commands.PunishCommand(playerName, true, false, kickReason).publish();
}
});
informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + playerName + " for " + durationString + "."));
if (!silent)
{
informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + playerName + " for " + durationString + "."));
}
}
else
{
@ -181,9 +189,19 @@ public class Punish extends MiniPlugin
//Warning
if (finalDuration == 0)
informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + playerName + "."));
{
if (!silent)
{
informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + playerName + "."));
}
}
else
informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + "."));
{
if (!silent)
{
informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + "."));
}
}
//Inform
Player target = UtilPlayer.searchExact(playerName);
@ -207,14 +225,14 @@ public class Punish extends MiniPlugin
}
}, playerName, category.toString(), sentence, reason, duration, caller == null ? "Mineplex Anti-Cheat" : caller.getName(), severity);
}, playerName, category.toString(), sentence, reason, duration, callerName == null ? "Mineplex Anti-Cheat" : callerName, severity);
}
private void informOfPunish(String punishee, String msg)
{
for (Player player : UtilServer.getPlayers())
{
if (_clientManager.Get(player).GetRank().Has(Rank.HELPER) || player.getName().equals(punishee))
if (_clientManager.Get(player).GetRank().has(Rank.HELPER) || player.getName().equals(punishee))
{
player.sendMessage(msg);
}

View File

@ -28,7 +28,7 @@ public class PunishmentHandler implements CommandCallback
String playerName = punishCommand.getPlayerName();
boolean ban = punishCommand.getBan();
final String reason = punishCommand.getMessage();
final Player player = Bukkit.getPlayer(playerName);
final Player player = Bukkit.getPlayerExact(playerName);
if (player != null && player.isOnline())
{

View File

@ -137,7 +137,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener
examplePrefixNote + "Give Warning if 0 Past Offences and 0 Warnings.",
}, 1, false, true), new PunishButton(this, Category.ChatOffense, 1, false, getDuration(Category.ChatOffense, 1, offenseMap)));
if (_plugin.GetClients().Get(_player).GetRank().Has(Rank.MODERATOR))
if (_plugin.GetClients().Get(_player).GetRank().has(Rank.MODERATOR))
{
AddButton(28, new ShopItem(Material.INK_SACK, (byte)11, "Severity 2", new String[] {
ChatColor.RESET + "Past Offences: " + ChatColor.YELLOW + offenseMap.get(Category.ChatOffense).get(2),
@ -221,7 +221,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener
examplePrefixEx + " Player Radar",
}, 1, false, true), new PunishButton(this, Category.Hacking, 1, true, getDuration(Category.Hacking, 1, offenseMap)));
if (_plugin.GetClients().Get(_player).GetRank().Has(Rank.MODERATOR))
if (_plugin.GetClients().Get(_player).GetRank().has(Rank.MODERATOR))
{
AddButton(32, new ShopItem(Material.INK_SACK, (byte)11, "Severity 2",new String[]
@ -274,7 +274,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener
}, 1, false, true), new PunishButton(this, Category.Warning, 1, false, 0));
if (_plugin.GetClients().Get(_player).GetRank().Has(Rank.MODERATOR))
if (_plugin.GetClients().Get(_player).GetRank().has(Rank.MODERATOR))
{
AddButton(34, new ShopItem(Material.REDSTONE_BLOCK, (byte)0, "Permanent Ban", new String[] {
ChatColor.RESET + "Ban Duration: " + ChatColor.YELLOW + "Permanent",

View File

@ -391,7 +391,7 @@ public class RewardManager
//Dont give Rank Upgrade if already has Legend
if (rarity == RewardRarity.MYTHICAL)
{
if (!canGiveMythical || _clientManager.Get(player).GetRank().Has(Rank.LEGEND))
if (!canGiveMythical || _clientManager.Get(player).GetRank().has(Rank.LEGEND))
{
rarity = RewardRarity.LEGENDARY;
}

View File

@ -58,7 +58,7 @@ public class RankReward extends Reward
@Override
public boolean canGiveReward(Player player)
{
return !_clientManager.Get(player).GetRank().Has(Rank.LEGEND);
return !_clientManager.Get(player).GetRank().has(Rank.LEGEND);
}
@Override

View File

@ -39,7 +39,7 @@ public class PlayerScoreboard
for (Rank rank : Rank.values())
{
if (rank != Rank.ALL)
_scoreboard.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " ");
_scoreboard.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " ");
else
_scoreboard.registerNewTeam(rank.Name).setPrefix("");
}
@ -54,12 +54,12 @@ public class PlayerScoreboard
String rankName = _manager.getClients().Get(player).GetRank().Name;
String otherRankName = _manager.getClients().Get(otherPlayer).GetRank().Name;
if (!_manager.getClients().Get(player).GetRank().Has(Rank.ULTRA) && _manager.getDonation().Get(player.getName()).OwnsUltraPackage())
if (!_manager.getClients().Get(player).GetRank().has(Rank.ULTRA) && _manager.getDonation().Get(player.getName()).OwnsUltraPackage())
{
rankName = Rank.ULTRA.Name;
}
if (!_manager.getClients().Get(otherPlayer).GetRank().Has(Rank.ULTRA) && _manager.getDonation().Get(otherPlayer.getName()).OwnsUltraPackage())
if (!_manager.getClients().Get(otherPlayer).GetRank().has(Rank.ULTRA) && _manager.getDonation().Get(otherPlayer.getName()).OwnsUltraPackage())
{
otherRankName = Rank.ULTRA.Name;
}

View File

@ -14,7 +14,7 @@ public class ScoreboardElementRank extends ScoreboardElement
{
ArrayList<String> output = new ArrayList<String>();
if (manager.getClients().Get(player).GetRank().Has(Rank.ULTRA))
if (manager.getClients().Get(player).GetRank().has(Rank.ULTRA))
{
output.add(manager.getClients().Get(player).GetRank().Name);
}

View File

@ -56,7 +56,7 @@ public class ServerConfiguration extends MiniPlugin
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event)
{
if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.HELPER, false))
if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false))
event.disallow(Result.KICK_OTHER, "This is a staff only server.");
}

View File

@ -138,7 +138,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
{
_buttonMap.get(event.getRawSlot()).onClick(_player, event.getClick());
}
else if (event.getRawSlot() != -999)
else if (event.getRawSlot() >= 0)
{
if (event.getInventory().getTitle() == inventory.getInventoryName() && (inventory.getSize() <= event.getSlot() || inventory.getItem(event.getSlot()) != null))
{

View File

@ -0,0 +1,123 @@
package mineplex.core.shop.page;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.item.IButton;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
public abstract class ShopPageInventory<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends
ShopPageBase
{
private int _page;
public ShopPageInventory(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager,
String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player, 54);
}
public PluginType getPlugin()
{
return (PluginType) super.getPlugin();
}
public ShopPageInventory(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager,
String name, Player player, int slots)
{
super(plugin, shop, clientManager, donationManager, name, player, slots);
}
protected abstract IButton[] getButtons();
protected abstract ItemStack[] getItems();
protected abstract void buildItems();
@Override
protected final void buildPage()
{
clearPage();
buildItems();
IButton[] buttons = getButtons();
ItemStack[] items = getItems();
int maxLen = Math.max(items.length, buttons.length);
boolean pages = maxLen > getSize();
_page = Math.max(0, Math.min(_page, pages ? (int) Math.ceil(maxLen / (double) (getSize() - 9)) - 1 : 0));
int start = pages ? _page * (getSize() - 9) : 0;
for (int slot = 0; slot < (pages ? getSize() - 9 : getSize()); slot++)
{
IButton button = null;
ItemStack item = null;
if (slot + start < buttons.length)
{
button = buttons[slot + start];
}
if (slot + start < items.length)
{
item = items[slot + start];
}
if (button != null)
{
super.addButton(slot, item, button);
}
else
{
setItem(slot, item);
}
}
if (pages)
{
for (int slot = 0; slot < 9; slot++)
{
int realSlot = getSize() - (9 - slot);
if ((slot == 0 && _page > 0) || (slot == 8 && maxLen > (_page + 1) * (getSize() - 9)))
{
final int nextPage = slot == 0 ? _page - 1 : _page + 1;
ItemBuilder builder = new ItemBuilder(Material.SIGN);
builder.setTitle(slot == 0 ? "Previous Page" : "Next Page");
builder.setAmount(nextPage + 1);
super.addButton(realSlot, builder.build(), new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
setPage(nextPage);
}
});
}
else if (slot == 4)
{
ItemStack item = new ItemBuilder(Material.PAPER).setTitle("Page " + (_page + 1)).setAmount(_page + 1).build();
setItem(realSlot, item);
}
}
}
}
public void setPage(int newPage)
{
_page = newPage;
buildPage();
}
}

View File

@ -10,6 +10,8 @@ public class PlayerStats
public long addStat(String statName, long value)
{
value = Math.max(0L, value);
if (!_statHash.containsKey(statName))
{
_statHash.put(statName, 0L);

Some files were not shown because too many files have changed in this diff Show More