Merge remote-tracking branch 'origin/master' into Myst_EVO
This commit is contained in:
commit
a0d0590777
12
.gitignore
vendored
12
.gitignore
vendored
@ -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
|
||||
|
@ -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>
|
@ -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>
|
@ -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 />
|
||||
|
@ -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" />
|
||||
|
@ -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" />
|
||||
|
BIN
Plugins/Libraries/Votifier.jar
Normal file
BIN
Plugins/Libraries/Votifier.jar
Normal file
Binary file not shown.
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ 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►");
|
||||
@ -97,22 +98,6 @@ 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);
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
@ -19,7 +18,6 @@ public class PlayerStats implements Listener, Runnable
|
||||
private Plugin _plugin;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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),
|
||||
@ -22,10 +23,12 @@ public enum Rank
|
||||
|
||||
EVENT("Event", ChatColor.WHITE),
|
||||
|
||||
//Staff ^^
|
||||
|
||||
//Media
|
||||
YOUTUBE("YouTube", ChatColor.RED),
|
||||
YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE),
|
||||
TWITCH("Twitch", ChatColor.DARK_PURPLE),
|
||||
|
||||
//Player
|
||||
LEGEND("Legend", ChatColor.GREEN, true),
|
||||
HERO("Hero", ChatColor.LIGHT_PURPLE, true),
|
||||
ULTRA("Ultra", ChatColor.AQUA, true),
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
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);
|
||||
|
||||
return UtilBlock.solid(ent.getLocation().getBlock().getRelative(BlockFace.DOWN));
|
||||
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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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>
|
29
Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java
Normal file
29
Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
@ -66,6 +72,11 @@ public class CoreClient
|
||||
_rank = rank;
|
||||
}
|
||||
|
||||
public long getNetworkSessionLoginTime()
|
||||
{
|
||||
return _networkSessionLoginTime;
|
||||
}
|
||||
|
||||
public String getDisguisedAs()
|
||||
{
|
||||
return _disguisedAs;
|
||||
@ -95,4 +106,9 @@ public class CoreClient
|
||||
public void setDisguised(boolean disguised) {
|
||||
this._disguised = disguised;
|
||||
}
|
||||
|
||||
public void setNetworkSessionLoginTime(long loginTime)
|
||||
{
|
||||
_networkSessionLoginTime = loginTime;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,9 +551,4 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
return client.GetRank().has(rank);
|
||||
}
|
||||
|
||||
public int getCachedClientAccountId(UUID uuid)
|
||||
{
|
||||
return _accountCacheRepository.getElement(uuid.toString()).getId();
|
||||
}
|
||||
}
|
@ -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),
|
||||
|
||||
|
@ -6,9 +6,11 @@ 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;
|
||||
|
||||
@ -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,
|
||||
@ -203,6 +217,11 @@ public enum AchievementCategory
|
||||
lore.add(" ");
|
||||
continue;
|
||||
}
|
||||
else if (_statDisplays[i].isJustDisplayName())
|
||||
{
|
||||
lore.add(ChatColor.RESET + _statDisplays[i].getDisplayName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String displayName = _statDisplays[i].getDisplayName();
|
||||
|
||||
@ -211,9 +230,21 @@ public enum AchievementCategory
|
||||
continue;
|
||||
|
||||
int statNumber = 0;
|
||||
|
||||
|
||||
// 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(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
|
||||
@ -224,8 +255,8 @@ public enum AchievementCategory
|
||||
}
|
||||
}
|
||||
|
||||
public static enum GameCategory
|
||||
public enum GameCategory
|
||||
{
|
||||
GLOBAL, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE;
|
||||
GLOBAL, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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>"));
|
||||
}
|
||||
}
|
||||
}
|
@ -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>"));
|
||||
}
|
||||
}
|
@ -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>"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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>"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -151,22 +151,48 @@ 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))) {
|
||||
try
|
||||
{
|
||||
if (player == null || player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (!player.getOpenInventory().getTopInventory().equals(_inv)))
|
||||
{
|
||||
end();
|
||||
return;
|
||||
}
|
||||
if (_inv == null) {
|
||||
|
||||
if (_inv == null)
|
||||
{
|
||||
_inv = Bukkit.createInventory(null, _size, _title);
|
||||
|
||||
setBackGround();
|
||||
setLoadingBarItems();
|
||||
UtilPlayer.swapToInventory(player, _inv);
|
||||
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||
} else
|
||||
}
|
||||
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() {
|
||||
HandlerList.unregisterAll(this);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,6 +44,8 @@ public class LagMeter extends MiniPlugin
|
||||
_clientManager = clientManager;
|
||||
_lastRun = System.currentTimeMillis();
|
||||
_lastAverage = System.currentTimeMillis();
|
||||
|
||||
_start = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -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()
|
||||
|
@ -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()
|
||||
@ -60,18 +60,18 @@ public class NotificationManager extends MiniPlugin
|
||||
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
@ -84,6 +84,19 @@ public class ServerCommand extends CommandBase<Portal>
|
||||
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]);
|
||||
|
@ -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;
|
||||
|
||||
//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;
|
||||
@ -255,12 +267,6 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
|
||||
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)
|
||||
{
|
||||
buildPreference(36, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
||||
@ -270,8 +276,15 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,12 +115,18 @@ public class Punish extends MiniPlugin
|
||||
}
|
||||
|
||||
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;
|
||||
@ -160,8 +166,7 @@ public class Punish extends MiniPlugin
|
||||
{
|
||||
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.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals";
|
||||
|
||||
Player target = UtilPlayer.searchOnline(null, playerName, false);
|
||||
if (target != null)
|
||||
@ -171,8 +176,11 @@ public class Punish extends MiniPlugin
|
||||
}
|
||||
});
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + playerName + " for " + durationString + "."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (caller == null)
|
||||
@ -181,9 +189,19 @@ public class Punish extends MiniPlugin
|
||||
|
||||
//Warning
|
||||
if (finalDuration == 0)
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + playerName + "."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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,7 +225,7 @@ 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)
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -1,28 +1,22 @@
|
||||
package mineplex.core.stats;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.EntityHuman;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.stats.command.GiveStatCommand;
|
||||
import mineplex.core.stats.command.TimeCommand;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
import mineplex.playerCache.PlayerCache;
|
||||
|
||||
public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
{
|
||||
@ -59,6 +53,33 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
PlayerStats playerStats = Get(event.getPlayer());
|
||||
|
||||
final int accountId = getClientManager().getAccountId(event.getPlayer());
|
||||
|
||||
for (String statName : playerStats.getStatsNames())
|
||||
{
|
||||
if (!_stats.containsKey(statName))
|
||||
continue;
|
||||
|
||||
final int statId = _stats.get(statName);
|
||||
|
||||
if (playerStats.getStat(statName) == -1)
|
||||
{
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.setStat(accountId, statId, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void incrementStat(final Player player, final String statName, final long value)
|
||||
{
|
||||
if (value <= 0)
|
||||
@ -72,7 +93,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
// Verify stat is in our local cache, if not add it remotely.
|
||||
if (!_stats.containsKey(statName))
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
@ -139,7 +160,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
if (player.isOnline())
|
||||
continue;
|
||||
|
||||
int uploadKey = ClientManager.getCachedClientAccountId(player.getUniqueId());
|
||||
int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId();
|
||||
|
||||
uploadQueue.put(uploadKey, new NautHashMap<Integer, Long>());
|
||||
|
||||
|
@ -26,9 +26,6 @@ import org.jooq.types.ULong;
|
||||
|
||||
public class StatsRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX nameIndex (name));";
|
||||
private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));";
|
||||
|
||||
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
|
||||
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
||||
|
||||
@ -38,16 +35,10 @@ public class StatsRepository extends RepositoryBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
//executeUpdate(CREATE_STAT_TABLE);
|
||||
//executeUpdate(CREATE_STAT_RELATION_TABLE);
|
||||
}
|
||||
protected void initialize() { }
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
}
|
||||
protected void update() { }
|
||||
|
||||
public List<Stat> retrieveStats()
|
||||
{
|
||||
@ -165,9 +156,36 @@ public class StatsRepository extends RepositoryBase
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
playerStats.addStat(resultSet.getString(1), resultSet.getInt(2));
|
||||
try
|
||||
{
|
||||
playerStats.addStat(resultSet.getString(1), resultSet.getLong(2));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
playerStats.addStat(resultSet.getString(1), -1);
|
||||
}
|
||||
}
|
||||
|
||||
return playerStats;
|
||||
}
|
||||
|
||||
public void setStat(int accountId, int statId, long value)
|
||||
{
|
||||
try
|
||||
{
|
||||
DSLContext context = DSL.using(getConnectionPool(), SQLDialect.MYSQL);
|
||||
|
||||
context
|
||||
.update(Tables.accountStat)
|
||||
.set(Tables.accountStat.value, ULong.valueOf(value))
|
||||
.where(Tables.accountStat.accountId.eq(accountId))
|
||||
.and(Tables.accountStat.statId.eq(statId))
|
||||
.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.task.repository.TaskRepository;
|
||||
import mineplex.playerCache.PlayerCache;
|
||||
|
||||
public class TaskManager extends MiniDbClientPlugin<TaskClient>
|
||||
{
|
||||
@ -68,7 +69,7 @@ public class TaskManager extends MiniDbClientPlugin<TaskClient>
|
||||
|
||||
synchronized (_taskLock)
|
||||
{
|
||||
final boolean success = _repository.addAccountTask(ClientManager.getCachedClientAccountId(uuid), _tasks.get(task));
|
||||
final boolean success = _repository.addAccountTask(PlayerCache.getInstance().getPlayer(uuid).getAccountId(), _tasks.get(task));
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
|
@ -336,7 +336,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (_clientManager.Get(name).GetRank() == Rank.ALL || !_clientManager.Get(name).GetRank().has(rank) || _clientManager.Get(name).GetRank() == rank)
|
||||
if (rank == Rank.ALL || _clientManager.Get(name).GetRank() == Rank.ALL || !_clientManager.Get(name).GetRank().has(rank) || _clientManager.Get(name).GetRank() == rank)
|
||||
{
|
||||
_clientManager.SaveRank(name, playerUUID, rank, perm);
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month."));
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import net.minecraft.server.v1_7_R4.MinecraftServer;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
@ -23,6 +24,7 @@ import mineplex.core.punish.Punish;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.spawn.Spawn;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
@ -79,7 +81,7 @@ public class Clans extends JavaPlugin
|
||||
BlockRestore blockRestore = new BlockRestore(this);
|
||||
|
||||
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
|
||||
Chat chat = new Chat(this, _clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
|
||||
Chat chat = new Chat(this, _clientManager, preferenceManager, new AchievementManager(new StatsManager(this, _clientManager), _clientManager, _donationManager), serverStatusManager.getCurrentServerName());
|
||||
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
|
||||
|
||||
new MemoryFix(this);
|
||||
|
@ -122,7 +122,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
|
||||
|
||||
PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager);
|
||||
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler);
|
||||
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish);
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
|
||||
|
||||
|
@ -47,6 +47,7 @@ import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.benefit.BenefitManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -80,6 +81,7 @@ import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
@ -157,7 +159,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
//Admin
|
||||
private boolean _gadgetsEnabled = true;
|
||||
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler)
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish)
|
||||
{
|
||||
super("Hub Manager", plugin);
|
||||
|
||||
@ -211,6 +213,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
_packetHandler = packetHandler;
|
||||
|
||||
new NotificationManager(getPlugin(), clientManager);
|
||||
new BotSpamManager(plugin, clientManager, punish);
|
||||
|
||||
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
||||
|
||||
@ -866,7 +869,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
return UtilTime.elapsed(_portalTime.get(player.getName()), 5000);
|
||||
}
|
||||
|
||||
public boolean CanBump(LivingEntity ent)
|
||||
public boolean hasPlayerStackingEnabled(LivingEntity ent)
|
||||
{
|
||||
if (!(ent instanceof Player))
|
||||
return true;
|
||||
@ -906,7 +909,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
@EventHandler
|
||||
public void ignoreVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR) && _preferences.Get(event.getPlayer()).IgnoreVelocity)
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.Get(event.getPlayer()).IgnoreVelocity)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV))
|
||||
if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH))
|
||||
{
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
|
@ -40,6 +40,11 @@ public class JumpManager extends MiniPlugin
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
if (Manager.getPreferences().Get(player).Invisibility)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Chicken Cancel
|
||||
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
|
||||
if (disguise != null &&
|
||||
@ -70,6 +75,12 @@ public class JumpManager extends MiniPlugin
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
continue;
|
||||
|
||||
if (Manager.getPreferences().Get(player).Invisibility)
|
||||
{
|
||||
player.setAllowFlight(true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Manager.GetParkour().isParkourMode(player))
|
||||
{
|
||||
player.setAllowFlight(false);
|
||||
|
@ -83,8 +83,9 @@ public class SoccerManager extends MiniPlugin
|
||||
private Vector _ballVel;
|
||||
private long _ballDeadTime = -1;
|
||||
|
||||
private String _lastKicker = "";
|
||||
private Color _lastKick = null;
|
||||
private String _lastRedKicker = "";
|
||||
private String _lastBlueKicker = "";
|
||||
private Color _lastKickColor = null;
|
||||
|
||||
//Item Rebound
|
||||
protected Vector _vel;
|
||||
@ -176,7 +177,7 @@ public class SoccerManager extends MiniPlugin
|
||||
if (_ball == null)
|
||||
return;
|
||||
|
||||
if (_lastKick == Color.AQUA)
|
||||
if (_lastKickColor == Color.AQUA)
|
||||
{
|
||||
for (int i = 0 ; i < 3 ; i++)
|
||||
UtilParticle.PlayParticle(ParticleType.RED_DUST, _ball.getLocation().add(0.0, 0.5, 0.0), -1, 1, 1, 1, 0,
|
||||
@ -213,13 +214,22 @@ public class SoccerManager extends MiniPlugin
|
||||
|
||||
UtilAction.zeroVelocity(player);
|
||||
|
||||
_lastKick = getTeamColor(player);
|
||||
if (_lastKick == null)
|
||||
_lastKicker = player.getName();
|
||||
else if (_lastKick == Color.RED)
|
||||
_lastKicker = C.cRed + player.getName();
|
||||
else if (_lastKick == Color.AQUA)
|
||||
_lastKicker = C.cAqua + player.getName();
|
||||
_lastKickColor = getTeamColor(player);
|
||||
if (_lastKickColor == Color.RED)
|
||||
{
|
||||
_lastRedKicker = C.cRed + player.getName();
|
||||
|
||||
if (_lastBlueKicker.length() == 0)
|
||||
_lastBlueKicker = C.cRed + player.getName();
|
||||
}
|
||||
|
||||
else if (_lastKickColor == Color.AQUA)
|
||||
{
|
||||
_lastBlueKicker = C.cAqua + player.getName();
|
||||
|
||||
if (_lastRedKicker.length() == 0)
|
||||
_lastRedKicker = C.cRed + player.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,14 +249,15 @@ public class SoccerManager extends MiniPlugin
|
||||
|
||||
for (Player player : _active)
|
||||
UtilTextMiddle.display("Goal! (" + C.cRed + _redGoals + C.cWhite + " : " + C.cBlue + _blueGoals + C.cWhite + ")",
|
||||
_lastKicker + C.cWhite + " scored for " + C.cAqua + "Blue Team", 0, 70, 20, player);
|
||||
_lastBlueKicker + C.cWhite + " scored for " + C.cAqua + "Blue Team", 0, 70, 20, player);
|
||||
|
||||
_ball.remove();
|
||||
_ball = null;
|
||||
|
||||
_lastRedKicker = "";
|
||||
_lastBlueKicker = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -264,10 +275,13 @@ public class SoccerManager extends MiniPlugin
|
||||
|
||||
for (Player player : _active)
|
||||
UtilTextMiddle.display("Goal! (" + C.cRed + _redGoals + C.cWhite + " : " + C.cBlue + _blueGoals + C.cWhite + ")",
|
||||
_lastKicker + C.cWhite + " scored for " + C.cRed + "Red Team", 0, 70, 20, player);
|
||||
_lastRedKicker + C.cWhite + " scored for " + C.cRed + "Red Team", 0, 70, 20, player);
|
||||
|
||||
_ball.remove();
|
||||
_ball = null;
|
||||
|
||||
_lastRedKicker = "";
|
||||
_lastBlueKicker = "";
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -95,12 +95,6 @@ public class StackerManager extends MiniPlugin implements IThrown
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Manager.CanBump(stacker))
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", "You are not playing stacker."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (stacker.getVehicle() != null || _tempStackShift.contains(stacker))
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack while stacked..."));
|
||||
@ -123,9 +117,15 @@ public class StackerManager extends MiniPlugin implements IThrown
|
||||
|
||||
if (stackee instanceof Player)
|
||||
{
|
||||
if (!Manager.CanBump(((Player)stackee)))
|
||||
if (!Manager.hasPlayerStackingEnabled(stacker))
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is not playing stacker."));
|
||||
UtilPlayer.message(stacker, F.main("Stacker", "You have player stacking disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Manager.hasPlayerStackingEnabled(((Player)stackee)))
|
||||
{
|
||||
UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " has player stacking disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ public class StackerManager extends MiniPlugin implements IThrown
|
||||
if (target.getCustomName() != null || (target.getPassenger() != null && target.getPassenger() instanceof LivingEntity && ((LivingEntity)target.getPassenger()).getCustomName() != null))
|
||||
return;
|
||||
|
||||
if (!Manager.CanBump(target))
|
||||
if (!Manager.hasPlayerStackingEnabled(target))
|
||||
return;
|
||||
|
||||
//Velocity
|
||||
|
@ -31,6 +31,7 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Silverfish;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Snowman;
|
||||
@ -44,6 +45,7 @@ import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
@ -163,6 +165,12 @@ public class WorldManager extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BlockEntityChange(EntityChangeBlockEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void Explosion(EntityExplodeEvent event)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.hub.server.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -8,25 +9,26 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementCategory;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.shop.page.ShopPageInventory;
|
||||
import mineplex.hub.server.ServerInfo;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.hub.server.ServerSorter;
|
||||
import mineplex.hub.server.ui.button.JoinServerButton;
|
||||
|
||||
public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> implements IServerPage
|
||||
public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcShop> implements IServerPage
|
||||
{
|
||||
// Shop Item Messages
|
||||
private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Tournament servers!";
|
||||
@ -40,6 +42,9 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
private String _serverGroupName;
|
||||
private boolean _onMainPage = true;
|
||||
|
||||
private IButton[] _buttons;
|
||||
private ItemStack[] _items;
|
||||
|
||||
public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroupName)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, name, player, 54);
|
||||
@ -50,13 +55,15 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
protected void buildItems()
|
||||
{
|
||||
_items = new ItemStack[0];
|
||||
_buttons = new IButton[0];
|
||||
|
||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>(getPlugin().getServerList(_serverGroupName));
|
||||
|
||||
int slotsNeeded = 1;
|
||||
|
||||
|
||||
if (serverList.size() > 0)
|
||||
{
|
||||
slotsNeeded = getPlugin().getRequiredSlots(getPlayer(), serverList.get(0).ServerType);
|
||||
@ -81,6 +88,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
getPlugin().selectServer(player, _serverGroupName);
|
||||
}
|
||||
});
|
||||
|
||||
buildAvailableServerPage(serverList, slotsNeeded);
|
||||
}
|
||||
else
|
||||
@ -109,7 +117,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
ChatColor.RESET + C.cGreen + "www.mineplex.com/shop"
|
||||
}, seconds, false, false);
|
||||
|
||||
addItem(22, item);
|
||||
addItemStack(22, item);
|
||||
}
|
||||
|
||||
private ShopItem buildShopItem(ServerInfo serverInfo, int slotsNeeded)
|
||||
@ -220,7 +228,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
ChatColor.RESET + "Visit " + C.cGreen + "www.mineplex.com/shop" + C.cWhite + "!"
|
||||
}, 1, false, false);
|
||||
|
||||
addItem(22, item);
|
||||
addItemStack(22, item);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -243,9 +251,6 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slot >= 54)
|
||||
continue;
|
||||
|
||||
addButton(slot, getPrivateItem(serverInfo), new JoinServerButton(this, serverInfo));
|
||||
slot++;
|
||||
}
|
||||
@ -273,7 +278,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
greenCount++;
|
||||
|
||||
if (serverInfo.MOTD.contains("Open in"))
|
||||
setItem(slot, shopItem);
|
||||
addItemStack(slot, shopItem);
|
||||
else
|
||||
{
|
||||
addButton(slot, shopItem, new JoinServerButton(this, serverInfo));
|
||||
@ -303,11 +308,39 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
{
|
||||
for (int i = greenCount + greenStartSlot; i < greenStartSlot + serversToShow; i++)
|
||||
{
|
||||
setItem(i, null);
|
||||
addItemStack(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addItemStack(int slot, ItemStack item)
|
||||
{
|
||||
if (_items.length <= slot)
|
||||
{
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_items = Arrays.copyOf(_items, slot + 1);
|
||||
_buttons = Arrays.copyOf(_buttons, slot + 1);
|
||||
}
|
||||
|
||||
_items[slot] = item;
|
||||
}
|
||||
|
||||
protected void addButton(int slot, ItemStack item, IButton button)
|
||||
{
|
||||
if (_items.length <= slot)
|
||||
{
|
||||
_items = Arrays.copyOf(_items, slot + 1);
|
||||
_buttons = Arrays.copyOf(_buttons, slot + 1);
|
||||
}
|
||||
|
||||
_items[slot] = item;
|
||||
_buttons[slot] = button;
|
||||
}
|
||||
|
||||
private ShopItem getPrivateItem(ServerInfo serverInfo)
|
||||
{
|
||||
String hostName = serverInfo.Name.substring(0, serverInfo.Name.indexOf('-'));
|
||||
@ -372,35 +405,46 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
{
|
||||
int slot = 9;
|
||||
|
||||
ArrayList<ServerInfo> inProgress = new ArrayList<ServerInfo>();
|
||||
|
||||
for (ServerInfo serverInfo : serverList)
|
||||
{
|
||||
if (isInProgress(serverInfo) && slot < getSize())
|
||||
if (isInProgress(serverInfo))
|
||||
{
|
||||
inProgress.add(serverInfo);
|
||||
}
|
||||
}
|
||||
|
||||
for (ServerInfo serverInfo : inProgress)
|
||||
{
|
||||
if (inProgress.size() > 45 && slot > 9 && slot % 45 == 0)
|
||||
{
|
||||
addBackBed(slot + 4);
|
||||
slot += 9;
|
||||
}
|
||||
|
||||
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
|
||||
|
||||
addButton(slot, shopItem, new JoinServerButton(this, serverInfo));
|
||||
|
||||
slot++;
|
||||
}
|
||||
|
||||
addBackBed(4);
|
||||
}
|
||||
|
||||
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
|
||||
private void addBackBed(int slot)
|
||||
{
|
||||
addButton(slot, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]
|
||||
{}, 1, false), new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
clear();
|
||||
_onMainPage = true;
|
||||
buildPage();
|
||||
}
|
||||
});
|
||||
|
||||
while (slot < getSize())
|
||||
{
|
||||
if (getItem(slot) != null)
|
||||
setItem(slot, null);
|
||||
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
@ -422,4 +466,16 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
|
||||
getPlugin().selectServer(player, serverInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IButton[] getButtons()
|
||||
{
|
||||
return _buttons;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack[] getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,19 @@ import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
public class PlayerCache
|
||||
{
|
||||
private static PlayerCache _instance = null;
|
||||
|
||||
private RedisDataRepository<PlayerInfo> _repository;
|
||||
|
||||
public PlayerCache()
|
||||
public static PlayerCache getInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new PlayerCache();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
private PlayerCache()
|
||||
{
|
||||
_repository = new RedisDataRepository<PlayerInfo>(
|
||||
ServerManager.getMasterConnection(),
|
||||
@ -21,14 +31,32 @@ public class PlayerCache
|
||||
}
|
||||
|
||||
public void addPlayer(PlayerInfo player)
|
||||
{
|
||||
try
|
||||
{
|
||||
_repository.addElement(player, 60 * 60 * 6); // 6 Hours
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("Error adding player info in PlayerCache : " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerInfo getPlayer(UUID uuid)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _repository.getElement(uuid.toString());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("Error retrieving player info in PlayerCache : " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clean()
|
||||
{
|
||||
|
@ -2,11 +2,13 @@ package mineplex.playerCache;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.Utility;
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
public class PlayerInfo implements Data
|
||||
{
|
||||
private int _id;
|
||||
private int _accountId;
|
||||
private UUID _uuid;
|
||||
private String _name;
|
||||
private boolean _online;
|
||||
@ -34,6 +36,11 @@ public class PlayerInfo implements Data
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public UUID getUUID()
|
||||
{
|
||||
return _uuid;
|
||||
@ -83,4 +90,14 @@ public class PlayerInfo implements Data
|
||||
{
|
||||
_version = version;
|
||||
}
|
||||
|
||||
public void setAccountId(int accountId)
|
||||
{
|
||||
_accountId = accountId;
|
||||
}
|
||||
|
||||
public void updateLoginTime()
|
||||
{
|
||||
_loginTime = Utility.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import com.google.gson.GsonBuilder;
|
||||
*/
|
||||
public class Utility
|
||||
{
|
||||
private static boolean _retrievedRedisTime = false;
|
||||
private static long _millisTimeDifference;
|
||||
|
||||
// The Gson instance used to serialize/deserialize objects in JSON form.
|
||||
private static Gson _gson = new GsonBuilder().create();
|
||||
@ -74,29 +76,10 @@ public class Utility
|
||||
*/
|
||||
public static long currentTimeSeconds()
|
||||
{
|
||||
long currentTime = 0;
|
||||
JedisPool pool = getPool(false);
|
||||
Jedis jedis = pool.getResource();
|
||||
if (!_retrievedRedisTime)
|
||||
setTimeDifference();
|
||||
|
||||
try
|
||||
{
|
||||
currentTime = Long.parseLong(jedis.time().get(0));
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
pool.returnBrokenResource(jedis);
|
||||
jedis = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (pool != null)
|
||||
{
|
||||
pool.returnResource(jedis);
|
||||
}
|
||||
}
|
||||
|
||||
return currentTime;
|
||||
return (System.currentTimeMillis() + _millisTimeDifference) / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,29 +88,10 @@ public class Utility
|
||||
*/
|
||||
public static long currentTimeMillis()
|
||||
{
|
||||
long currentTime = 0;
|
||||
JedisPool pool = getPool(false);
|
||||
Jedis jedis = pool.getResource();
|
||||
if (!_retrievedRedisTime)
|
||||
setTimeDifference();
|
||||
|
||||
try
|
||||
{
|
||||
currentTime = Long.parseLong(jedis.time().get(0));
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
pool.returnBrokenResource(jedis);
|
||||
jedis = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (pool != null)
|
||||
{
|
||||
pool.returnResource(jedis);
|
||||
}
|
||||
}
|
||||
|
||||
return currentTime * 1000;
|
||||
return System.currentTimeMillis() + _millisTimeDifference;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,4 +152,30 @@ public class Utility
|
||||
return connData.getHost() + ":" + connData.getPort();
|
||||
}
|
||||
|
||||
private static void setTimeDifference()
|
||||
{
|
||||
long currentTime = 0;
|
||||
JedisPool pool = getPool(false);
|
||||
Jedis jedis = pool.getResource();
|
||||
|
||||
try
|
||||
{
|
||||
currentTime = Long.parseLong(jedis.time().get(0));
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
pool.returnBrokenResource(jedis);
|
||||
jedis = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (pool != null)
|
||||
{
|
||||
pool.returnResource(jedis);
|
||||
}
|
||||
}
|
||||
|
||||
_millisTimeDifference = (currentTime * 1000) - System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package mineplex.serverdata.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerJoinCommand extends ServerCommand
|
||||
{
|
||||
private String _uuid;
|
||||
|
||||
public PlayerJoinCommand(UUID uuid)
|
||||
{
|
||||
_uuid = uuid.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// Utilitizes a callback functionality to seperate dependencies
|
||||
}
|
||||
|
||||
public String getUuid()
|
||||
{
|
||||
return _uuid;
|
||||
}
|
||||
}
|
@ -16,6 +16,8 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -42,10 +44,12 @@ public class ServerMonitor
|
||||
private static Map<String, ServerGroup> _serverGroupMap = null;
|
||||
private static List<DedicatedServer> _dedicatedServers = null;
|
||||
private static HashSet<String> _deadServers = new HashSet<String>();
|
||||
private static HashSet<String> _delayedKill = new HashSet<String>();
|
||||
private static HashSet<String> _laggyServers = new HashSet<String>();
|
||||
|
||||
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
||||
private static Logger _logger = Logger.getLogger("ServerMonitor");
|
||||
private static Timer _timer = new Timer();
|
||||
|
||||
private static int _totalPlayers = 0;
|
||||
private static Region _region;
|
||||
@ -123,6 +127,8 @@ public class ServerMonitor
|
||||
}
|
||||
|
||||
for (MinecraftServer minecraftServer : _serverStatuses)
|
||||
{
|
||||
if (!ignoreServer(minecraftServer.getGroup()))
|
||||
{
|
||||
if (minecraftServer.getMotd().contains("Finished") || (minecraftServer.getGroup().equalsIgnoreCase("UltraHardcore") && minecraftServer.getMotd().contains("Restarting") && minecraftServer.getPlayerCount() == 0))
|
||||
{
|
||||
@ -131,6 +137,7 @@ public class ServerMonitor
|
||||
handleUserServerGroup(_serverGroupMap.get(minecraftServer.getGroup()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (DedicatedServer server : _dedicatedServers)
|
||||
{
|
||||
@ -202,6 +209,9 @@ public class ServerMonitor
|
||||
|
||||
for (ServerGroup groupStatus : _serverGroups)
|
||||
{
|
||||
if (ignoreServer(groupStatus.getName()))
|
||||
continue;
|
||||
|
||||
NautHashMap<Integer, MinecraftServer> serverMap = new NautHashMap<Integer, MinecraftServer>();
|
||||
|
||||
for (Iterator<MinecraftServer> serverIterator = groupStatus.getServers().iterator(); serverIterator.hasNext();)
|
||||
@ -226,17 +236,6 @@ public class ServerMonitor
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (groupStatus.getHost() == null || groupStatus.getHost().isEmpty())
|
||||
{
|
||||
if (groupStatus.getName().startsWith("0"))
|
||||
{
|
||||
int serverCount = groupStatus.getServers().size();
|
||||
log(groupStatus.getName() + " : " + groupStatus.getPlayerCount() + " players on " + serverCount + " servers " + String.format("%.2f", ((double)serverCount * (double)groupStatus.getRequiredCpu() / totalCPU)) + "% CPU," + String.format("%.2f", ((double)serverCount * (double)groupStatus.getRequiredRam() / totalRAM)) + "% RAM", false);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
HashSet<String> onlineServers = new HashSet<String>();
|
||||
@ -246,7 +245,7 @@ public class ServerMonitor
|
||||
|
||||
for (MinecraftServer minecraftServer : _serverStatuses)
|
||||
{
|
||||
if (minecraftServer.getGroup().equalsIgnoreCase("Testing"))
|
||||
if (ignoreServer(minecraftServer.getGroup()))
|
||||
continue;
|
||||
|
||||
onlineServers.add(minecraftServer.getName());
|
||||
@ -288,7 +287,7 @@ public class ServerMonitor
|
||||
|
||||
for (ServerGroup serverGroup : _serverGroups)
|
||||
{
|
||||
if (serverGroup.getName().equals("Testing"))
|
||||
if (ignoreServer(serverGroup.getName()))
|
||||
continue;
|
||||
|
||||
try
|
||||
@ -386,22 +385,36 @@ public class ServerMonitor
|
||||
deadServers.addAll(_deadServers);
|
||||
|
||||
_deadServers.clear();
|
||||
for (MinecraftServer deadServer : _repository.getDeadServers())
|
||||
for (final MinecraftServer deadServer : _repository.getDeadServers())
|
||||
{
|
||||
if (deadServer.getUptime() <= 10 || deadServer.getGroup().equalsIgnoreCase("Testing"))
|
||||
if (deadServer.getUptime() <= 10 || ignoreServer(deadServer.getGroup()))
|
||||
continue;
|
||||
|
||||
if (_count == 0 || deadServers.contains(deadServer.getName()))
|
||||
{
|
||||
copyServerLog(deadServer);
|
||||
killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true);
|
||||
|
||||
handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup()));
|
||||
}
|
||||
else
|
||||
else if (!_delayedKill.contains(deadServer.getName()))
|
||||
{
|
||||
startTimingReport(deadServer);
|
||||
|
||||
_timer.schedule(new TimerTask()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_deadServers.add(deadServer.getName());
|
||||
_delayedKill.remove(deadServer.getName());
|
||||
|
||||
stopTimingReport(deadServer);
|
||||
log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress());
|
||||
}
|
||||
}, 20 * 1000);
|
||||
|
||||
_delayedKill.add(deadServer.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,20 +454,26 @@ public class ServerMonitor
|
||||
// Minimum 1500 slot bufferzone
|
||||
if (serverGroup.getName().equalsIgnoreCase("Lobby"))
|
||||
{
|
||||
if (_region == Region.EU)
|
||||
{
|
||||
requiredTotal = 10;
|
||||
requiredJoinable = 10;
|
||||
}
|
||||
|
||||
int availableSlots = serverGroup.getMaxPlayerCount() - serverGroup.getPlayerCount();
|
||||
|
||||
if (availableSlots < 1500)
|
||||
if (availableSlots < 1000)
|
||||
{
|
||||
serversToAdd = Math.max(1, (1500 - availableSlots) / serverGroup.getMaxPlayers());
|
||||
serversToAdd = Math.max(1, (1000 - availableSlots) / serverGroup.getMaxPlayers());
|
||||
serversToAdd = Math.min(250 - totalServers, serversToAdd);
|
||||
serversToKill = 0;
|
||||
}
|
||||
else if (serversToKill > 0)
|
||||
serversToKill = Math.min(serversToKill, (availableSlots - 1500) / 80);
|
||||
serversToKill = Math.min(serversToKill, (availableSlots - 1000) / 80);
|
||||
else if (serversToAdd == 0 && joinableServers > requiredJoinable && totalServers > requiredTotal)
|
||||
{
|
||||
serversToRestart = Math.min(joinableServers - requiredJoinable, joinableServers - requiredTotal);
|
||||
serversToRestart = Math.min(serversToRestart, (availableSlots - 1500) / 80);
|
||||
serversToRestart = Math.min(serversToRestart, (availableSlots - 1000) / 80);
|
||||
|
||||
if (serversToRestart <= 5)
|
||||
serversToRestart = 0;
|
||||
@ -486,7 +505,7 @@ public class ServerMonitor
|
||||
if (joinableServers > maxUHC)
|
||||
serversToKill = maxUHC - joinableServers;
|
||||
}
|
||||
else if (serverGroup.getName().equalsIgnoreCase("Testing"))
|
||||
else if (ignoreServer(serverGroup.getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -653,6 +672,105 @@ public class ServerMonitor
|
||||
killServer(serverToKill.getName(), serverToKill.getPublicAddress(), serverToKill.getPlayerCount(), message, true);
|
||||
}
|
||||
|
||||
private static void startTimingReport(final MinecraftServer server)
|
||||
{
|
||||
if (_debug)
|
||||
return;
|
||||
|
||||
String cmd = "/home/mineplex/remoteStartTiming.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
{
|
||||
if (error)
|
||||
log("[TIMING START] Errored " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
else
|
||||
log("[TIMING START] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
}
|
||||
|
||||
private static void stopTimingReport(final MinecraftServer server)
|
||||
{
|
||||
if (_debug)
|
||||
return;
|
||||
|
||||
String cmd = "/home/mineplex/remoteStopTiming.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
{
|
||||
if (error)
|
||||
log("[TIMING PASTE] Errored " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
else
|
||||
log("[TIMING PASTE] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
}
|
||||
|
||||
private static void copyServerLog(final MinecraftServer server)
|
||||
{
|
||||
if (_debug)
|
||||
return;
|
||||
|
||||
String cmd = "/home/mineplex/easyRemoteCopyLog.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
{
|
||||
if (error)
|
||||
log("[COPY LOG] Errored " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
else
|
||||
log("[COPY LOG] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
}
|
||||
|
||||
private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free)
|
||||
{
|
||||
if (_debug)
|
||||
@ -691,6 +809,11 @@ public class ServerMonitor
|
||||
_processes.add(pr);
|
||||
}
|
||||
|
||||
private static boolean ignoreServer(String serverGroupName)
|
||||
{
|
||||
return serverGroupName.equalsIgnoreCase("Testing") || serverGroupName.equalsIgnoreCase("Clans");
|
||||
}
|
||||
|
||||
private static void log(String message)
|
||||
{
|
||||
log(message, false);
|
||||
|
@ -3,16 +3,19 @@ package mineplex.servermonitor;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.data.DedicatedServer;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
import mineplex.servermonitor.data.BungeeStatusData;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
public class StatusHistoryRepository
|
||||
{
|
||||
@ -25,15 +28,14 @@ public class StatusHistoryRepository
|
||||
private static String CREATE_BUNGEE_TABLE = "CREATE TABLE IF NOT EXISTS BungeeStats (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(25), updated LONG, players INT, maxPlayers INT, alive BOOLEAN NOT NULL, online BOOLEAN NOT NULL, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));";
|
||||
private static String CREATE_NETWORKSTATS_TABLE = "CREATE TABLE IF NOT EXISTS NetworkStats (id INT NOT NULL AUTO_INCREMENT, updated LONG, players INT, totalNetworkCpuUsage DOUBLE(4,2), totalNetworkRamUsage DOUBLE(4,2), totalCpu MEDIUMINT, totalRam MEDIUMINT, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));";
|
||||
|
||||
private static String RETRIEVE_BUNGEE_STATUSES = "SELECT bungeeStatus.address, bungeeStatus.players, bungeeStatus.maxPlayers, bungeeStatus.US, onlineStatus.online, now(), bungeeStatus.updated FROM BungeeServers AS bungeeStatus INNER JOIN bungeeOnlineStatus AS onlineStatus ON onlineStatus.address = bungeeStatus.address";
|
||||
|
||||
private static String INSERT_SERVERGROUP_STATS = "INSERT INTO ServerGroupStats (serverGroup, updated, players, maxPlayers, totalNetworkCpuUsage, totalNetworkRamUsage, totalCpu, totalRam, US) VALUES (?, now(), ?, ?, ?, ?, ?, ?, ?);";
|
||||
private static String INSERT_DEDICATEDSERVER_STATS = "INSERT INTO DedicatedServerStats (serverName, address, updated, cpu, ram, usedCpuPercent, usedRamPercent, US) VALUES (?, ?, now(), ?, ?, ?, ?, ?);";
|
||||
private static String INSERT_BUNGEE_STATS = "INSERT INTO BungeeStats (address, updated, players, maxPlayers, alive, online, US) VALUES (?, now(), ?, ?, ?, ?, ?);";
|
||||
private static String INSERT_NETWORK_STATS = "INSERT INTO NetworkStats (updated, players, totalNetworkCpuUsage, totalNetworkRamUsage, totalCpu, totalRam, US) VALUES (now(), ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
private static Connection _connection;
|
||||
private static Connection _bungeeconnection;
|
||||
|
||||
private static DataRepository<BungeeServer> _repository;
|
||||
|
||||
public StatusHistoryRepository()
|
||||
{
|
||||
@ -65,6 +67,9 @@ public class StatusHistoryRepository
|
||||
preparedStatement = _connection.prepareStatement(CREATE_NETWORKSTATS_TABLE);
|
||||
preparedStatement.execute();
|
||||
preparedStatement.close();
|
||||
|
||||
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL),
|
||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -185,58 +190,16 @@ public class StatusHistoryRepository
|
||||
|
||||
public void saveNetworkStats(double usedCpuPercent, double usedRamPercent, double availableCPU, double availableRAM, Region region)
|
||||
{
|
||||
/*
|
||||
int totalPlayers = 0;
|
||||
|
||||
List<BungeeStatusData> bungeeStatuses = new ArrayList<BungeeStatusData>();
|
||||
PreparedStatement retrieveStatement = null;
|
||||
List<BungeeServer> bungeeServers = new ArrayList<BungeeServer>(_repository.getElements());
|
||||
|
||||
try
|
||||
for (Iterator<BungeeServer> bungeeIterator = bungeeServers.iterator(); bungeeIterator.hasNext();)
|
||||
{
|
||||
if (_bungeeconnection == null || _bungeeconnection.isClosed())
|
||||
_bungeeconnection = DriverManager.getConnection(_bungeeConnectionString, _userName, _password);
|
||||
BungeeServer server = bungeeIterator.next();
|
||||
|
||||
retrieveStatement = _bungeeconnection.prepareStatement(RETRIEVE_BUNGEE_STATUSES);
|
||||
ResultSet resultSet = retrieveStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
BungeeStatusData bungeeData = new BungeeStatusData();
|
||||
bungeeData.Address = resultSet.getString(1);
|
||||
bungeeData.Players = resultSet.getInt(2);
|
||||
bungeeData.MaxPlayers = resultSet.getInt(3);
|
||||
bungeeData.US = resultSet.getBoolean(4);
|
||||
bungeeData.Online = resultSet.getBoolean(5);
|
||||
|
||||
long now = resultSet.getLong(6);
|
||||
long updated = resultSet.getLong(7);
|
||||
|
||||
bungeeData.Alive = (now - updated) <= 15;
|
||||
|
||||
if (bungeeData.Alive && bungeeData.US == (region == Region.US))
|
||||
totalPlayers += bungeeData.Players;
|
||||
|
||||
if (bungeeData.US == (region == Region.US))
|
||||
bungeeStatuses.add(bungeeData);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (retrieveStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
retrieveStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (server.getPublicAddress().equalsIgnoreCase("127.0.0.1") || server.getPublicAddress().equalsIgnoreCase("0.0.0.0"))
|
||||
bungeeIterator.remove();
|
||||
}
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
@ -248,14 +211,15 @@ public class StatusHistoryRepository
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_BUNGEE_STATS);
|
||||
|
||||
for (BungeeStatusData bungeeStatusData : bungeeStatuses)
|
||||
for (BungeeServer bungeeStatusData : bungeeServers)
|
||||
{
|
||||
preparedStatement.setString(1, bungeeStatusData.Address);
|
||||
preparedStatement.setInt(2, bungeeStatusData.Players);
|
||||
preparedStatement.setInt(3, bungeeStatusData.MaxPlayers);
|
||||
preparedStatement.setBoolean(4, bungeeStatusData.Alive);
|
||||
preparedStatement.setBoolean(5, bungeeStatusData.Online);
|
||||
preparedStatement.setBoolean(6, bungeeStatusData.US);
|
||||
totalPlayers += bungeeStatusData.getPlayerCount();
|
||||
preparedStatement.setString(1, bungeeStatusData.getPublicAddress());
|
||||
preparedStatement.setInt(2, bungeeStatusData.getPlayerCount());
|
||||
preparedStatement.setInt(3, bungeeStatusData.getPlayerCount());
|
||||
preparedStatement.setBoolean(4, true);
|
||||
preparedStatement.setBoolean(5, true);
|
||||
preparedStatement.setBoolean(6, bungeeStatusData.getRegion() == Region.US);
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
|
||||
@ -315,6 +279,5 @@ public class StatusHistoryRepository
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.8.0_60"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -1,11 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
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
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
@ -4,6 +4,8 @@ import java.io.File;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.FoodDupeFix;
|
||||
import org.omg.CORBA._PolicyStub;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.BiomeBase;
|
||||
@ -154,6 +156,7 @@ public class Arcade extends JavaPlugin
|
||||
new MemoryFix(this);
|
||||
new CustomTagFix(this, packetHandler);
|
||||
new TablistFix(this);
|
||||
new FoodDupeFix(this);
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
@ -111,6 +111,7 @@ import nautilus.game.arcade.addons.TeamArmorAddon;
|
||||
import nautilus.game.arcade.addons.compass.CompassAddon;
|
||||
import nautilus.game.arcade.command.DisguiseCommand;
|
||||
import nautilus.game.arcade.command.GameCommand;
|
||||
import nautilus.game.arcade.command.RequiredRankCommand;
|
||||
import nautilus.game.arcade.command.WriteCommand;
|
||||
import nautilus.game.arcade.command.KitUnlockCommand;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
@ -211,6 +212,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
//Youtuber Kits
|
||||
private HashSet<Player> _youtube = new HashSet<Player>();
|
||||
|
||||
//Server Property
|
||||
private Rank _requiredRank;
|
||||
|
||||
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
|
||||
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
||||
StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat,
|
||||
@ -414,6 +418,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
});
|
||||
|
||||
getPacketHandler().addPacketHandler(_resourcePacketHandler);
|
||||
|
||||
loadRequiredRank();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -423,6 +429,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
addCommand(new WriteCommand(this));
|
||||
addCommand(new KitUnlockCommand(this));
|
||||
addCommand(new DisguiseCommand(this));
|
||||
addCommand(new RequiredRankCommand(this));
|
||||
}
|
||||
|
||||
public GameServerConfig GetServerConfig()
|
||||
@ -785,6 +792,34 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
if (Bukkit.getServer().hasWhitelist())
|
||||
{
|
||||
if(_requiredRank != null)
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), _requiredRank, false))
|
||||
{
|
||||
event.allow();
|
||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
|
||||
if (_serverConfig.Tournament && _clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false))
|
||||
{
|
||||
event.getPlayer().setOp(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(event.getPlayer().getName()))
|
||||
{
|
||||
event.allow();
|
||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Required Rank for this server: " + _requiredRank.getColor() + _requiredRank.Name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false))
|
||||
{
|
||||
event.allow();
|
||||
@ -1490,4 +1525,38 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadRequiredRank()
|
||||
{
|
||||
_requiredRank = null;
|
||||
|
||||
for(File file : new File(".").listFiles())
|
||||
{
|
||||
if(!file.getName().startsWith("RequiredRank"))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
_requiredRank = Rank.valueOf(file.getName().split("=")[1]);
|
||||
System.out.println("set required rank to " + _requiredRank.Name);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
System.out.println("===============================");
|
||||
System.out.println("Wrong required rank definition.");
|
||||
System.out.println("[" + file.getName().split("=")[1] + "] Does not exist!");
|
||||
System.out.println("===============================");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Rank getRequiredRank()
|
||||
{
|
||||
return _requiredRank;
|
||||
}
|
||||
|
||||
public void setRequiredRank(Rank rank)
|
||||
{
|
||||
_requiredRank = rank;
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class CompassAddon extends MiniPlugin
|
||||
{
|
||||
// Teleport to nearest player when you left click compass
|
||||
|
||||
if (!Recharge.Instance.use(player, "Spectate", 5000, true, false))
|
||||
if (!Recharge.Instance.use(player, "Spectate", 3000, true, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package nautilus.game.arcade.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class RequiredRankCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
|
||||
private ArcadeManager _manager;
|
||||
|
||||
public RequiredRankCommand(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, new Rank[]{Rank.JNR_DEV}, "Requiredrank");
|
||||
_manager = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if(!_manager.getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Command", "This is not a test server.."));
|
||||
return;
|
||||
}
|
||||
if(args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Command", "Invalid rank input."));
|
||||
return;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("Reset"))
|
||||
{
|
||||
_manager.setRequiredRank(null);
|
||||
UtilPlayer.message(caller, F.main("Command", "You reset the required rank to null."));
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
Rank rank = Rank.valueOf(args[0]);
|
||||
_manager.setRequiredRank(rank);
|
||||
UtilPlayer.message(caller, F.main("Command", "You set the required rank to: " + rank.getColor() + rank.Name));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Command", "Invalid rank input."));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -73,6 +73,7 @@ public class GameTeam
|
||||
|
||||
//Records order players go out in
|
||||
protected ArrayList<Player> _places = new ArrayList<Player>();
|
||||
private long _teamCreatedTime = System.currentTimeMillis(); // Used just for SpectatorPage so that teams remain ordered
|
||||
|
||||
public GameTeam(Game host, String name, ChatColor color, ArrayList<Location> spawns, boolean tags)
|
||||
{
|
||||
@ -90,6 +91,11 @@ public class GameTeam
|
||||
this(host, name, color, spawns, false);
|
||||
}
|
||||
|
||||
public long getCreatedTime()
|
||||
{
|
||||
return _teamCreatedTime;
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return _name;
|
||||
@ -300,6 +306,11 @@ public class GameTeam
|
||||
_displayName = name;
|
||||
}
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
return _displayName;
|
||||
}
|
||||
|
||||
public byte GetColorData()
|
||||
{
|
||||
if (GetColor() == ChatColor.WHITE) return (byte)0;
|
||||
|
@ -1,53 +1,83 @@
|
||||
package nautilus.game.arcade.game.games.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseBat;
|
||||
import mineplex.core.disguise.disguises.DisguiseChicken;
|
||||
import mineplex.core.disguise.disguises.DisguiseEnderman;
|
||||
import mineplex.core.disguise.disguises.DisguiseWither;
|
||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.give.Give;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.event.kits.KitPlayer;
|
||||
import nautilus.game.arcade.game.games.sheep.kits.KitBrute;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.managers.GameHostManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.sun.xml.internal.ws.resources.UtilMessages;
|
||||
|
||||
public class EventGame extends Game
|
||||
{
|
||||
@ -66,6 +96,11 @@ public class EventGame extends Game
|
||||
private boolean _allowAllGadgets = false;
|
||||
private HashSet<SalesPackageBase> _gadgetWhitelist = new HashSet<SalesPackageBase>();
|
||||
|
||||
private HashMap<Sign, Long> _functionSigns;
|
||||
private ArrayList<Sign> _powerdedSigns;
|
||||
|
||||
private HashMap<Integer, EventArea> _customAreas;
|
||||
|
||||
public EventGame(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Event,
|
||||
@ -106,12 +141,81 @@ public class EventGame extends Game
|
||||
this.InventoryOpenBlock = true;
|
||||
this.InventoryOpenChest = true;
|
||||
|
||||
|
||||
//Dont timeout
|
||||
this.GameTimeout = -1;
|
||||
|
||||
_mps = manager.GetGameHostManager();
|
||||
_functionSigns = new HashMap<>();
|
||||
_powerdedSigns = new ArrayList<>();
|
||||
|
||||
this.CreatureAllow = true;
|
||||
|
||||
_customAreas = new HashMap<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void registerSigns(GameStateChangeEvent event)
|
||||
{
|
||||
if(event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
for(Location loc : WorldData.GetDataLocs("RED"))
|
||||
{
|
||||
for(int i = -5; i < 5; i++)
|
||||
{
|
||||
Location temp = loc.clone().add(0, i, 0);
|
||||
if(temp.getBlock().getType() == Material.SIGN_POST || temp.getBlock().getType() == Material.WALL_SIGN)
|
||||
{
|
||||
if(!_functionSigns.containsKey((Sign) temp.getBlock().getState()))
|
||||
{
|
||||
_functionSigns.put((Sign) temp.getBlock().getState(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void registerAreas(GameStateChangeEvent event)
|
||||
{
|
||||
if(event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
for(String name : WorldData.GetAllCustomLocs().keySet())
|
||||
{
|
||||
try
|
||||
{
|
||||
EventArea area = new EventArea(Integer.parseInt(name.split(" ")[0]));
|
||||
Location tempA = WorldData.GetAllCustomLocs().get(name).get(0);
|
||||
Location tempB = WorldData.GetAllCustomLocs().get(name).get(1);
|
||||
area.CornerA = new Location(tempA.getWorld(), Math.min(tempA.getX(), tempB.getX()), Math.min(tempA.getY(), tempB.getY()), Math.min(tempA.getZ(), tempB.getZ()));
|
||||
area.CornerB = new Location(tempA.getWorld(), Math.max(tempA.getX(), tempB.getX()), Math.max(tempA.getY(), tempB.getY()), Math.max(tempA.getZ(), tempB.getZ()));
|
||||
area.DamageAll = name.contains("ALL");
|
||||
area.DamagePvP = name.contains("PVP");
|
||||
area.DamagePvE = name.contains("PVE");
|
||||
area.DamageEvP = name.contains("EVP");
|
||||
area.Usable = true;
|
||||
_customAreas.put(Integer.parseInt(name.split(" ")[0]), area);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Error while parsing area locs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void signPlace(SignChangeEvent event)
|
||||
{
|
||||
if(!IsLive())
|
||||
return;
|
||||
|
||||
if(!Manager.GetGameHostManager().isAdmin(event.getPlayer(), true))
|
||||
return;
|
||||
|
||||
if(event.getLine(0).startsWith("[") && event.getLine(0).endsWith("]"))
|
||||
_functionSigns.put((Sign) event.getBlock().getState(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
//Before GamePlayerManager puts onto Spec!
|
||||
@ -464,4 +568,733 @@ public class EventGame extends Game
|
||||
return losers;
|
||||
}
|
||||
|
||||
/*@EventHandler
|
||||
public void signCheck(BlockRedstoneEvent event)
|
||||
{
|
||||
if(event.getBlock().getType() != Material.SIGN_POST && event.getBlock().getType() != Material.WALL_SIGN)
|
||||
return;
|
||||
|
||||
useSign(((Sign) event.getBlock().getState()).getLines());
|
||||
}*/
|
||||
|
||||
@EventHandler
|
||||
public void signClock(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for(Sign sign : _functionSigns.keySet())
|
||||
{
|
||||
|
||||
Sign cooldown = null;
|
||||
|
||||
for(BlockFace face : BlockFace.values())
|
||||
{
|
||||
if(face == BlockFace.UP)
|
||||
continue;
|
||||
|
||||
if(sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getType() == Material.WALL_SIGN)
|
||||
{
|
||||
cooldown = (Sign) sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getState();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(cooldown == null)
|
||||
{
|
||||
if(!sign.getBlock().isBlockPowered())
|
||||
{
|
||||
_powerdedSigns.remove(sign);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(_powerdedSigns.contains(sign))
|
||||
continue;
|
||||
|
||||
useSign(sign, ((Sign) sign.getBlock().getState()).getLines());
|
||||
|
||||
if(sign.getBlock().isBlockPowered())
|
||||
{
|
||||
if(!_powerdedSigns.contains(sign))
|
||||
{
|
||||
_powerdedSigns.add(sign);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!sign.getBlock().isBlockPowered() && !UtilTime.elapsed(_functionSigns.get(sign), Long.parseLong(cooldown.getLine(0)) * 1000))
|
||||
continue;
|
||||
|
||||
if(!sign.getBlock().isBlockPowered())
|
||||
{
|
||||
_powerdedSigns.remove(sign);
|
||||
}
|
||||
|
||||
if(_powerdedSigns.contains(sign))
|
||||
continue;
|
||||
|
||||
_functionSigns.put(sign, System.currentTimeMillis());
|
||||
useSign(sign, ((Sign) sign.getBlock().getState()).getLines());
|
||||
|
||||
if(sign.getBlock().isBlockPowered())
|
||||
{
|
||||
if(!_powerdedSigns.contains(sign))
|
||||
{
|
||||
_powerdedSigns.add(sign);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void useSign(final Sign sign, String[] args)
|
||||
{
|
||||
String command = args[0];
|
||||
String playerName = args[1];
|
||||
|
||||
HashMap<Integer, ArrayList<Player>> varMap = new HashMap<>();
|
||||
|
||||
int i = 0;
|
||||
for(String varArgs : args)
|
||||
{
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
if(Bukkit.getPlayer(varArgs) != null)
|
||||
players.add(Bukkit.getPlayer(varArgs));
|
||||
|
||||
if(varArgs.contentEquals("@p"))
|
||||
{
|
||||
for(Player player : GetPlayers(true))
|
||||
{
|
||||
boolean found;
|
||||
found = true;
|
||||
for(Player otherPlayer : GetPlayers(true))
|
||||
{
|
||||
if(player == otherPlayer)
|
||||
continue;
|
||||
|
||||
if(UtilMath.offset(sign.getLocation(), player.getLocation()) >= UtilMath.offset(sign.getLocation(), otherPlayer.getLocation()))
|
||||
{
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found)
|
||||
{
|
||||
players.add(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(playerName.contains("@a"))
|
||||
{
|
||||
int radius = 0;
|
||||
if(playerName.contains("r="))
|
||||
{
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(playerName.split("=")[1]);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
for(Player player : GetPlayers(true))
|
||||
{
|
||||
if(UtilMath.offset(sign.getLocation(), player.getLocation()) <= radius || radius <= 0)
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
varMap.put(i, players);
|
||||
i++;
|
||||
}
|
||||
|
||||
if(command.contentEquals("[BC]"))
|
||||
{
|
||||
String message = args[1];
|
||||
for(int e = 2; e <= 3; e++)
|
||||
message += " " + args[e];
|
||||
|
||||
String colored = ChatColor.translateAlternateColorCodes('&', message);
|
||||
this.Announce(F.main("Event", colored), true);
|
||||
}
|
||||
|
||||
if(command.contentEquals("[TELEPORT]"))
|
||||
{
|
||||
for(Player player : varMap.get(1))
|
||||
{
|
||||
if(Bukkit.getPlayer(args[2]) != null)
|
||||
{
|
||||
player.teleport(Bukkit.getPlayer(args[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] coords = args[2].split(" ");
|
||||
int x = Integer.parseInt(coords[0]);
|
||||
int y = Integer.parseInt(coords[1]);
|
||||
int z = Integer.parseInt(coords[2]);
|
||||
player.teleport(new Location(sign.getWorld(), x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(command.contentEquals("[MESSAGE]"))
|
||||
{
|
||||
String message = args[2];
|
||||
message += " " + args[3];
|
||||
|
||||
String colored = ChatColor.translateAlternateColorCodes('&', message);
|
||||
|
||||
for(Player player : varMap.get(1))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Event", colored));
|
||||
}
|
||||
}
|
||||
|
||||
if(command.contentEquals("[SETBLOCK]"))
|
||||
{
|
||||
Material mat = Material.getMaterial(Integer.parseInt(args[1]));
|
||||
String[] coords = args[2].split(" ");
|
||||
int x = Integer.parseInt(coords[0]);
|
||||
int y = Integer.parseInt(coords[1]);
|
||||
int z = Integer.parseInt(coords[2]);
|
||||
sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).setType(mat);
|
||||
}
|
||||
|
||||
if(command.contentEquals("[TESTFOR]"))
|
||||
{
|
||||
boolean redstone = false;
|
||||
Material mat = Material.getMaterial(Integer.parseInt(args[1]));
|
||||
if(args[2].contains("r="))
|
||||
{
|
||||
int radius = 0;
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(args[2].split("=")[1]);
|
||||
if(radius >= 30)
|
||||
radius = 30;
|
||||
|
||||
for(int x = -radius + sign.getLocation().getBlockX(); x < radius + sign.getLocation().getBlockX(); x++)
|
||||
{
|
||||
for(int y = -radius + sign.getLocation().getBlockY(); y < radius + sign.getLocation().getBlockY(); y++)
|
||||
{
|
||||
for(int z = -radius + sign.getLocation().getBlockZ(); z < radius + sign.getLocation().getBlockZ(); z++)
|
||||
{
|
||||
if(sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).getType() == mat)
|
||||
{
|
||||
redstone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] coords = args[2].split(" ");
|
||||
int x = Integer.parseInt(coords[0]);
|
||||
int y = Integer.parseInt(coords[1]);
|
||||
int z = Integer.parseInt(coords[2]);
|
||||
if(sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).getType() == mat)
|
||||
{
|
||||
redstone = true;
|
||||
}
|
||||
}
|
||||
if(redstone)
|
||||
{
|
||||
for(final BlockFace face : BlockFace.values())
|
||||
{
|
||||
if(face != BlockFace.UP
|
||||
&& face != BlockFace.NORTH_WEST
|
||||
&& face != BlockFace.NORTH_EAST
|
||||
&& face != BlockFace.SOUTH_EAST
|
||||
&& face != BlockFace.SOUTH_WEST)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(sign.getBlock().getRelative(face).getType() != Material.AIR)
|
||||
continue;
|
||||
|
||||
if(sign.getBlock().getRelative(face).isBlockPowered())
|
||||
continue;
|
||||
|
||||
sign.getBlock().getRelative(face).setType(Material.REDSTONE_BLOCK);
|
||||
|
||||
Manager.runSyncLater(new Runnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
sign.getBlock().getRelative(face).setType(Material.AIR);
|
||||
}
|
||||
|
||||
}, 3L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(varMap.get(1).isEmpty())
|
||||
return;
|
||||
|
||||
String[] vars = new String[args.length - 1];
|
||||
vars[0] = args[0];
|
||||
vars[1] = args[2];
|
||||
vars[2] = args[3];
|
||||
|
||||
String tempArgs = "";
|
||||
for(String str : vars)
|
||||
{
|
||||
for(String string : str.split(" "))
|
||||
{
|
||||
tempArgs += string + " ";
|
||||
}
|
||||
}
|
||||
String[] commandArgs = tempArgs.split(" ");
|
||||
|
||||
if(command.contentEquals("[MOB]"))
|
||||
{
|
||||
for(Player player : varMap.get(1))
|
||||
Manager.GetEventModule().commandMob(player, commandArgs);
|
||||
}
|
||||
if(command.contentEquals("[SCORE]"))
|
||||
{
|
||||
for(Player player : varMap.get(1))
|
||||
Manager.GetEventModule().commandScoreboard(player, vars);
|
||||
}
|
||||
if(command.contentEquals("[GIVE]"))
|
||||
{
|
||||
try
|
||||
{
|
||||
for(Player player : varMap.get(1))
|
||||
{
|
||||
player.getInventory().addItem(new ItemStack(Material.getMaterial(Integer.parseInt(args[2])), Integer.parseInt(args[3])));
|
||||
}
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
if(command.contentEquals("[DOUBLEJUMP]"))
|
||||
{
|
||||
for(Player player : varMap.get(1))
|
||||
Manager.GetEventModule().commandDoubleJump(player, vars);
|
||||
}
|
||||
if(command.contentEquals("[EFFECT]"))
|
||||
{
|
||||
//Manager.GetEventModule().commandEffect(Manager.GetGameHostManager().getHost(), commandArgs, varMap.get(1));
|
||||
for(Player player : varMap.get(1))
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(args[2]), Integer.parseInt(args[3].split(" ")[0]), Integer.parseInt(args[3].split(" ")[1])));
|
||||
}
|
||||
|
||||
}
|
||||
if(command.contentEquals("[KIT]"))
|
||||
{
|
||||
for(Player player : varMap.get(1))
|
||||
Manager.GetEventModule().commandKit(player, commandArgs);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void signBreak(BlockBreakEvent event)
|
||||
{
|
||||
if(event.getBlock().getType() == Material.SIGN_POST || event.getBlock().getType() == Material.WALL_SIGN || event.getBlock().getType() == Material.SIGN)
|
||||
{
|
||||
Iterator<Sign> signIter = _functionSigns.keySet().iterator();
|
||||
while(signIter.hasNext())
|
||||
{
|
||||
Sign sign = signIter.next();
|
||||
if(sign.getLocation().getBlockX() == event.getBlock().getLocation().getBlockX()
|
||||
&& sign.getLocation().getBlockY() == event.getBlock().getLocation().getBlockY()
|
||||
&& sign.getLocation().getBlockZ() == event.getBlock().getLocation().getBlockZ())
|
||||
{
|
||||
signIter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInArea(EventArea area, Entity entity)
|
||||
{
|
||||
if(entity.getLocation().getX() < area.CornerA.getX() || entity.getLocation().getX() > area.CornerB.getX())
|
||||
return false;
|
||||
|
||||
if(entity.getLocation().getY() < area.CornerA.getY() || entity.getLocation().getY() > area.CornerB.getY())
|
||||
return false;
|
||||
|
||||
if(entity.getLocation().getZ() < area.CornerA.getZ() || entity.getLocation().getZ() > area.CornerB.getZ())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void activateGadget(GadgetActivateEvent event)
|
||||
{
|
||||
for(EventArea area : _customAreas.values())
|
||||
{
|
||||
if(area.CornerA == null || area.CornerB == null)
|
||||
continue;
|
||||
|
||||
if(area.Usable == false)
|
||||
continue;
|
||||
|
||||
if(!isInArea(area, event.getPlayer()))
|
||||
continue;
|
||||
|
||||
if(!area.GadgetsEnabled.contains(event.getGadget()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void areaPotionEffect(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
for(EventArea area : _customAreas.values())
|
||||
{
|
||||
for(Player player : GetPlayers(true))
|
||||
{
|
||||
if(area.CornerA == null || area.CornerB == null)
|
||||
continue;
|
||||
|
||||
if(area.Usable == false)
|
||||
continue;
|
||||
|
||||
if(!isInArea(area, player))
|
||||
continue;
|
||||
|
||||
for(PotionEffectType type : area.PotionEffects.keySet())
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(type, 60, area.PotionEffects.get(type)), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void areaDamage(CustomDamageEvent event)
|
||||
{
|
||||
for(EventArea area : _customAreas.values())
|
||||
{
|
||||
if(area.CornerA == null || area.CornerB == null)
|
||||
continue;
|
||||
|
||||
if(area.Usable == false)
|
||||
continue;
|
||||
|
||||
if(Manager.GetEventModule().getDamagePlayers().contains(event.GetDamagerPlayer(true)))
|
||||
{
|
||||
if(!Manager.GetGame().DamagePvP)
|
||||
{
|
||||
Manager.GetGame().Damage = true;
|
||||
Manager.GetGame().DamagePvP = true;
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
Manager.GetGame().DamagePvP = false;
|
||||
Manager.GetGame().Damage = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isInArea(area, event.GetDamageeEntity()))
|
||||
continue;
|
||||
|
||||
if(!area.DamageAll)
|
||||
{
|
||||
event.SetCancelled("Event Area");
|
||||
continue;
|
||||
}
|
||||
if(event.GetCause() == DamageCause.ENTITY_ATTACK && event.GetDamagerPlayer(true) == null)
|
||||
{
|
||||
if(!area.DamageEvP)
|
||||
{
|
||||
event.SetCancelled("Event Area");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(!(event.GetDamageeEntity() instanceof Player))
|
||||
{
|
||||
if(!area.DamagePvE)
|
||||
{
|
||||
event.SetCancelled("Event Area");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if((event.GetDamageeEntity() instanceof Player) && (event.GetDamagerEntity(true) instanceof Player))
|
||||
{
|
||||
if(!area.DamagePvP)
|
||||
{
|
||||
event.SetCancelled("Event Area");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(!Manager.GetGame().DamagePvP)
|
||||
{
|
||||
Manager.GetGame().Damage = true;
|
||||
Manager.GetGame().DamagePvP = true;
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
Manager.GetGame().DamagePvP = false;
|
||||
Manager.GetGame().Damage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void listAreaSettings(Player player)
|
||||
{
|
||||
for(EventArea area : _customAreas.values())
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Event", "============================"));
|
||||
UtilPlayer.message(player, F.main("Event", "Settings for area " + area.ID));
|
||||
UtilPlayer.message(player, F.oo("Damage All", area.DamageAll) + ", "
|
||||
+ F.oo("Damage PvP", area.DamagePvP) + ", "
|
||||
+ F.oo("Damage PvE", area.DamagePvE)
|
||||
+ ", " + F.oo("Damage EvP", area.DamageEvP));
|
||||
|
||||
UtilPlayer.message(player, F.main("Event", "Potion Effects for area " + area.ID));
|
||||
for(PotionEffectType type : area.PotionEffects.keySet())
|
||||
UtilPlayer.message(player, F.oo(type.getName(), true) + " level: " + area.PotionEffects.get(type));
|
||||
|
||||
UtilPlayer.message(player, F.main("Event", "Gadgets for area " + area.ID));
|
||||
for(SalesPackageBase gadget : area.GadgetsEnabled)
|
||||
UtilPlayer.message(player, F.oo(gadget.GetName(), true));
|
||||
}
|
||||
}
|
||||
|
||||
public void editArea(Player player, String[] args)
|
||||
{
|
||||
|
||||
if(args[1].equalsIgnoreCase("Info"))
|
||||
{
|
||||
listAreaSettings(player);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if(_customAreas.containsKey(Integer.parseInt(args[1])))
|
||||
{
|
||||
if(args[2].equalsIgnoreCase("Del"))
|
||||
{
|
||||
_customAreas.remove(Integer.parseInt(args[1]));
|
||||
UtilPlayer.message(player, F.main("Event", "Region deleted"));
|
||||
}
|
||||
if(args[2].equalsIgnoreCase("ALL"))
|
||||
{
|
||||
_customAreas.get(Integer.parseInt(args[1])).DamageAll = !_customAreas.get(Integer.parseInt(args[1])).DamageAll;
|
||||
UtilPlayer.message(player, F.main("Event", "Damage all for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageAll)));
|
||||
}
|
||||
if(args[2].equalsIgnoreCase("PVP"))
|
||||
{
|
||||
_customAreas.get(Integer.parseInt(args[1])).DamagePvP = !_customAreas.get(Integer.parseInt(args[1])).DamagePvP;
|
||||
UtilPlayer.message(player, F.main("Event", "Damage PvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamagePvP)));
|
||||
}
|
||||
if(args[2].equalsIgnoreCase("PVE"))
|
||||
{
|
||||
_customAreas.get(Integer.parseInt(args[1])).DamagePvE = !_customAreas.get(Integer.parseInt(args[1])).DamagePvE;
|
||||
UtilPlayer.message(player, F.main("Event", "Damage PvE for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamagePvE)));
|
||||
}
|
||||
if(args[2].equalsIgnoreCase("EVP"))
|
||||
{
|
||||
_customAreas.get(Integer.parseInt(args[1])).DamageEvP = !_customAreas.get(Integer.parseInt(args[1])).DamageEvP;
|
||||
UtilPlayer.message(player, F.main("Event", "Damage EvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageEvP)));
|
||||
}
|
||||
if(args[2].equalsIgnoreCase("Effect"))
|
||||
{
|
||||
PotionEffectType type = PotionEffectType.getByName(args[3]);
|
||||
if(_customAreas.get(Integer.parseInt(args[1])).PotionEffects.containsKey(type))
|
||||
{
|
||||
_customAreas.get(Integer.parseInt(args[1])).PotionEffects.remove(type);
|
||||
UtilPlayer.message(player, F.main("Event", "Removed potion effect from area"));
|
||||
return;
|
||||
}
|
||||
if (type == null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Effect", "Invalid Effect Type: " + args[2]));
|
||||
UtilPlayer.message(player, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect"));
|
||||
return;
|
||||
}
|
||||
int strenght = 0;
|
||||
try
|
||||
{
|
||||
strenght = Integer.parseInt(args[4]);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
_customAreas.get(Integer.parseInt(args[1])).PotionEffects.put(type, strenght);
|
||||
UtilPlayer.message(player, F.main("Event", "Potion Effect added for Region " + args[1]));
|
||||
}
|
||||
if(args[2].equalsIgnoreCase("Gadget"))
|
||||
{
|
||||
//Gadgets
|
||||
for (GadgetType type : GadgetType.values())
|
||||
{
|
||||
for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(type))
|
||||
{
|
||||
if (gadget.GetName().replaceAll(" ", "").equalsIgnoreCase(args[3]))
|
||||
{
|
||||
if (_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.remove(gadget))
|
||||
{
|
||||
Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget for area " + args[1], F.ed(false))));
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget for area " + args[1], F.ed(true))));
|
||||
_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.add(gadget);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mounts
|
||||
for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts())
|
||||
{
|
||||
if (mount.GetName().replaceAll(" ", "").equalsIgnoreCase(args[3]))
|
||||
{
|
||||
if (_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.remove(mount))
|
||||
{
|
||||
Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget for area " + args[1], F.ed(false))));
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget for area " + args[1], F.ed(true))));
|
||||
_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.add(mount);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Event", "No Area Found"));
|
||||
}
|
||||
if(args[2].equalsIgnoreCase("Add"))
|
||||
{
|
||||
if(!_customAreas.containsKey(Integer.parseInt(args[1])))
|
||||
_customAreas.put(Integer.parseInt(args[1]), new EventArea(Integer.parseInt(args[1])));
|
||||
|
||||
EventArea area = _customAreas.get(Integer.parseInt(args[1]));
|
||||
|
||||
if(args[3].equalsIgnoreCase("A"))
|
||||
{
|
||||
area.CornerA = player.getLocation();
|
||||
UtilPlayer.message(player, F.main("Event", "Corner A set!"));
|
||||
}
|
||||
if(args[3].equalsIgnoreCase("B"))
|
||||
{
|
||||
area.CornerB = player.getLocation();
|
||||
UtilPlayer.message(player, F.main("Event", "Corner B set!"));
|
||||
}
|
||||
if(area.CornerA != null && area.CornerB != null)
|
||||
{
|
||||
Location tempA = area.CornerA.clone();
|
||||
Location tempB = area.CornerB.clone();
|
||||
area.CornerA = new Location(tempA.getWorld(), Math.min(tempA.getX(), tempB.getX()), Math.min(tempA.getY(), tempB.getY()), Math.min(tempA.getZ(), tempB.getZ()));
|
||||
area.CornerB = new Location(tempA.getWorld(), Math.max(tempA.getX(), tempB.getX()), Math.max(tempA.getY(), tempB.getY()), Math.max(tempA.getZ(), tempB.getZ()));
|
||||
area.Usable = true;
|
||||
UtilPlayer.message(player, F.main("Event", "Region is Usable"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Event", "Error while executing command"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventChestDrop(PlayerDropItemEvent event)
|
||||
{
|
||||
if(event.getItemDrop() == null)
|
||||
return;
|
||||
|
||||
if(event.getItemDrop().getItemStack().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
if(!event.getItemDrop().getItemStack().hasItemMeta())
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void gemSign(final PlayerInteractEvent event)
|
||||
{
|
||||
if(event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if(event.getClickedBlock().getType() != Material.SIGN && event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
||||
return;
|
||||
|
||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||
if(!sign.getLine(0).contentEquals("(GEM)"))
|
||||
return;
|
||||
|
||||
final Material mat = Material.getMaterial(Integer.parseInt(sign.getLine(1)));
|
||||
Integer price = Integer.parseInt(sign.getLine(2));
|
||||
if(price > 500)
|
||||
price = 500;
|
||||
|
||||
if(price <= 0)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "You got an item for free."));
|
||||
event.getPlayer().getInventory().addItem(new ItemStack(mat));
|
||||
return;
|
||||
}
|
||||
|
||||
if(Manager.GetDonation().Get(event.getPlayer()).GetGems() < price)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "You dont have enough Gems."));
|
||||
return;
|
||||
}
|
||||
|
||||
final int gems = price;
|
||||
Manager.GetDonation().RewardGems(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "You bought an item for " + gems + " Gems."));
|
||||
event.getPlayer().getInventory().addItem(new ItemStack(mat));
|
||||
}
|
||||
}
|
||||
}, "Gem Sign", event.getPlayer().getName(), event.getPlayer().getUniqueId(), -price);
|
||||
}
|
||||
|
||||
public class EventArea
|
||||
{
|
||||
|
||||
public int ID;
|
||||
|
||||
public Location CornerA;
|
||||
public Location CornerB;
|
||||
|
||||
public boolean DamageAll;
|
||||
public boolean DamagePvP;
|
||||
public boolean DamagePvE;
|
||||
public boolean DamageEvP;
|
||||
|
||||
public boolean Usable;
|
||||
|
||||
public HashMap<PotionEffectType, Integer> PotionEffects;
|
||||
public HashSet<SalesPackageBase> GadgetsEnabled;
|
||||
|
||||
public EventArea(Integer id)
|
||||
{
|
||||
ID = id;
|
||||
Usable = false;
|
||||
PotionEffects = new HashMap<>();
|
||||
GadgetsEnabled = new HashSet<SalesPackageBase>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,23 +12,33 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilSystem;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.creature.event.CreatureKillEntitiesEvent;
|
||||
import mineplex.core.event.StackerEvent;
|
||||
import mineplex.core.gadget.gadgets.MorphBlock;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.give.Give;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Ageable;
|
||||
@ -36,16 +46,19 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -54,17 +67,26 @@ import org.bukkit.potion.PotionEffectType;
|
||||
public class EventModule extends MiniPlugin
|
||||
{
|
||||
|
||||
public ArcadeManager Manager;
|
||||
private ArcadeManager Manager;
|
||||
|
||||
private NautHashMap<PotionEffectType, Long> _potionEffectsDuration = new NautHashMap<>();
|
||||
private NautHashMap<PotionEffectType, Integer> _potionEffectsMult = new NautHashMap<>();
|
||||
|
||||
private boolean _mobGriefing = true;
|
||||
private boolean _mobGriefing;
|
||||
|
||||
private HashSet<Entity> _tempStackShift = new HashSet<Entity>();
|
||||
|
||||
private ArrayList<Player> _stacker;
|
||||
private ArrayList<Player> _damage;
|
||||
private boolean _allowStacker;
|
||||
|
||||
public EventModule(ArcadeManager manager, JavaPlugin plugin)
|
||||
{
|
||||
super("EventModule", plugin);
|
||||
Manager = manager;
|
||||
_mobGriefing = true;
|
||||
_stacker = new ArrayList<>();
|
||||
_damage = new ArrayList<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -110,7 +132,7 @@ public class EventModule extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private void commandHelp(Player player)
|
||||
public void commandHelp(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Event", "Displaying Commands;"));
|
||||
|
||||
@ -137,6 +159,12 @@ public class EventModule extends MiniPlugin
|
||||
UtilPlayer.message(player, F.value("/e give <player> <item> <amount> [e:#,e:#...]", "Give Item"));
|
||||
|
||||
UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump"));
|
||||
UtilPlayer.message(player, F.value("/e bc", "Broadcast a message with colorcodes"));
|
||||
UtilPlayer.message(player, F.value("/e tempgadget", "Activates gadget for all player"));
|
||||
UtilPlayer.message(player, F.value("/e playerdamage", "Toggles damage fpr player"));
|
||||
UtilPlayer.message(player, F.value("/e stacker [Player]", "toggles stacker global or for Players"));
|
||||
UtilPlayer.message(player, F.value("/e kick", "Remove a player from the event"));
|
||||
UtilPlayer.message(player, F.value("/e area PVP|ALL|PVE|EVP|Gadget|Effect / add", "Create and edit areas"));
|
||||
|
||||
UtilPlayer.message(player, F.value("/e scoreboard <Line #> [Text]", "Sets Scoreboard Text"));
|
||||
|
||||
@ -151,7 +179,7 @@ public class EventModule extends MiniPlugin
|
||||
UtilPlayer.message(player, F.value("/e effect <player> clear", ""));
|
||||
}
|
||||
|
||||
private void commandHelpSettings(Player player)
|
||||
public void commandHelpSettings(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;"));
|
||||
UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage"));
|
||||
@ -181,7 +209,7 @@ public class EventModule extends MiniPlugin
|
||||
|
||||
//Command Handler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
private void commandHandler(PlayerCommandPreprocessEvent event)
|
||||
public void commandHandler(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (!Manager.GetGame().InProgress())
|
||||
return;
|
||||
@ -257,7 +285,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("effect"))
|
||||
{
|
||||
commandEffect(event.getPlayer(), args);
|
||||
commandEffect(event.getPlayer(), args, null);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("kit"))
|
||||
{
|
||||
@ -356,17 +384,77 @@ public class EventModule extends MiniPlugin
|
||||
{
|
||||
commandBlockPlaceInCreative(event.getPlayer(), args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("blockbreakcreative"))
|
||||
else if(args[0].equalsIgnoreCase("stacker"))
|
||||
{
|
||||
commandBlockBreakInCreative(event.getPlayer(), args);
|
||||
commandStacker(event.getPlayer(), args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("playerdamage"))
|
||||
{
|
||||
if(args[1] == null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "Insufficient arguments!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(Bukkit.getPlayer(args[1]) == null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "This Player is not online!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(_damage.contains(Bukkit.getPlayer(args[1])))
|
||||
_damage.remove(Bukkit.getPlayer(args[1]));
|
||||
else
|
||||
_damage.add(Bukkit.getPlayer(args[1]));
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("bc"))
|
||||
{
|
||||
commandBC(event.getPlayer(), args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("area"))
|
||||
{
|
||||
if(!(Manager.GetGame() instanceof EventGame)) {
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Settings", "You can only edit areas in the Event game!"));
|
||||
return;
|
||||
}
|
||||
|
||||
((EventGame) Manager.GetGame()).editArea(event.getPlayer(), args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("mobgriefing"))
|
||||
{
|
||||
commandMobGriefing(event.getPlayer(), args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("kick"))
|
||||
{
|
||||
if(Bukkit.getPlayer(args[1]) == null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), "No matches for: " + C.cYellow + args[1]);
|
||||
return;
|
||||
}
|
||||
//Bukkit.getPlayer(args[1]).kickPlayer("You where kicked from the event, probably you didn't stick to the Event Rules.");
|
||||
Manager.GetGameHostManager().getBlacklist().add(Bukkit.getPlayer(args[1]).getName());
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "You removed " + C.cYellow + Bukkit.getPlayer(args[1]).getName()));
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("tempgadget"))
|
||||
{
|
||||
String gadget = args[1];
|
||||
for(int e = 2; e < args.length; e++)
|
||||
gadget+= " " + args[e];
|
||||
|
||||
try
|
||||
{
|
||||
for(Player target : UtilServer.getPlayers())
|
||||
Manager.GetDonation().Get(target).AddUnknownSalesPackagesOwned(gadget);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "Gadget is not vallid"));
|
||||
}
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "You gave the gadget " + F.item(gadget) + " to all Players!"));
|
||||
}
|
||||
}
|
||||
|
||||
private void listSettings(Player player)
|
||||
public void listSettings(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.value("Damage All", F.tf(Manager.GetGame().Damage)));
|
||||
UtilPlayer.message(player, F.value("Damage PvP", F.tf(Manager.GetGame().DamagePvP)));
|
||||
@ -389,28 +477,55 @@ public class EventModule extends MiniPlugin
|
||||
UtilPlayer.message(player, F.value("Mob griefing", F.tf(_mobGriefing)));
|
||||
}
|
||||
|
||||
private void commandBlockBreakInCreative(Player player, String[] args)
|
||||
public void commandBlockBreakInCreative(Player player, String[] args)
|
||||
{
|
||||
Manager.GetGame().BlockBreakCreative = !Manager.GetGame().BlockBreakCreative;
|
||||
|
||||
UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative)));
|
||||
}
|
||||
|
||||
private void commandBlockPlaceInCreative(Player player, String[] args)
|
||||
public void commandStacker(Player player, String[] args)
|
||||
{
|
||||
if(args.length == 1)
|
||||
{
|
||||
_allowStacker = !_allowStacker;
|
||||
UtilPlayer.message(player, F.main("Settings", "Stacker all: " + F.tf(_allowStacker)));
|
||||
}
|
||||
else
|
||||
{
|
||||
for(Player target : UtilPlayer.matchOnline(player, args[1], true))
|
||||
{
|
||||
if(_stacker.contains(target))
|
||||
{
|
||||
_stacker.remove(target);
|
||||
UtilPlayer.message(target, F.main("Settings", "Stacker: " + F.tf(false)));
|
||||
UtilPlayer.message(player, F.main("Settings", "Stacker " + target.getName() + ": " + F.tf(false)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_stacker.add(target);
|
||||
UtilPlayer.message(target, F.main("Settings", "Stacker: " + F.tf(true)));
|
||||
UtilPlayer.message(player, F.main("Settings", "Stacker " + target.getName() + ": " + F.tf(true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void commandBlockPlaceInCreative(Player player, String[] args)
|
||||
{
|
||||
Manager.GetGame().BlockPlaceCreative = !Manager.GetGame().BlockPlaceCreative;
|
||||
|
||||
UtilPlayer.message(player, F.main("Settings", "BlockPlaceCreative: " + F.tf(Manager.GetGame().BlockPlaceCreative)));
|
||||
}
|
||||
|
||||
private void commandMobGriefing(Player player, String[] args)
|
||||
public void commandMobGriefing(Player player, String[] args)
|
||||
{
|
||||
_mobGriefing = !_mobGriefing;
|
||||
|
||||
UtilPlayer.message(player, F.main("Settings", "Mob Griefing: " + F.tf(_mobGriefing)));
|
||||
}
|
||||
|
||||
private void commandBlockPlace(Player player, String[] args, boolean whitelist, String command)
|
||||
public void commandBlockPlace(Player player, String[] args, boolean whitelist, String command)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -471,7 +586,7 @@ public class EventModule extends MiniPlugin
|
||||
commandHelpSettings(player);
|
||||
}
|
||||
|
||||
private void commandBlockBreak(Player player, String[] args, boolean whitelist, String command)
|
||||
public void commandBlockBreak(Player player, String[] args, boolean whitelist, String command)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -532,7 +647,7 @@ public class EventModule extends MiniPlugin
|
||||
commandHelpSettings(player);
|
||||
}
|
||||
|
||||
private void commandHealth(Player player, String[] args)
|
||||
public void commandHealth(Player player, String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -563,7 +678,7 @@ public class EventModule extends MiniPlugin
|
||||
commandHelpSettings(player);
|
||||
}
|
||||
|
||||
private void commandHunger(Player player, String[] args)
|
||||
public void commandHunger(Player player, String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -594,7 +709,7 @@ public class EventModule extends MiniPlugin
|
||||
commandHelpSettings(player);
|
||||
}
|
||||
|
||||
private void commandTime(Player player, String[] args)
|
||||
public void commandTime(Player player, String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -626,7 +741,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Teleport Command (To, Here, All)
|
||||
private void commandTeleport(Player player, String[] args)
|
||||
public void commandTeleport(Player player, String[] args)
|
||||
{
|
||||
if (args.length >= 3 && args[1].equalsIgnoreCase("here"))
|
||||
{
|
||||
@ -668,7 +783,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Gadget Commands (Global & Individual)
|
||||
private void commandGadget(Player player, String[] args)
|
||||
public void commandGadget(Player player, String[] args)
|
||||
{
|
||||
if(!(Manager.GetGame() instanceof EventGame)) {
|
||||
UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable gadgets in the Event game!"));
|
||||
@ -780,7 +895,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Silence
|
||||
private void commandSilence(Player player, String[] args)
|
||||
public void commandSilence(Player player, String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -813,7 +928,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Gamemode (Self and Others)
|
||||
private void commandAdmin(Player player, String[] args)
|
||||
public void commandAdmin(Player player, String[] args)
|
||||
{
|
||||
Player target = player;
|
||||
|
||||
@ -835,7 +950,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Gamemode (Self and Others)
|
||||
private void commandGamemode(Player player, String[] args)
|
||||
public void commandGamemode(Player player, String[] args)
|
||||
{
|
||||
Player target = player;
|
||||
|
||||
@ -857,7 +972,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Forcefield
|
||||
private void commandForcefieldRadius(Player player, String[] args)
|
||||
public void commandForcefieldRadius(Player player, String[] args)
|
||||
{
|
||||
|
||||
if(!(Manager.GetGame() instanceof EventGame)) {
|
||||
@ -889,7 +1004,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Give
|
||||
private void commandGive(Player player, String[] args)
|
||||
public void commandGive(Player player, String[] args)
|
||||
{
|
||||
String[] newArgs = new String[args.length-1];
|
||||
|
||||
@ -900,7 +1015,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Spec
|
||||
private void commandSpectators(Player player, String[] args)
|
||||
public void commandSpectators(Player player, String[] args)
|
||||
{
|
||||
Manager.GetGame().JoinInProgress = !Manager.GetGame().JoinInProgress;
|
||||
|
||||
@ -908,7 +1023,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Deathout
|
||||
private void commandDeathout(Player player, String[] args)
|
||||
public void commandDeathout(Player player, String[] args)
|
||||
{
|
||||
Manager.GetGame().DeathOut = !Manager.GetGame().DeathOut;
|
||||
|
||||
@ -916,7 +1031,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//QuitOut
|
||||
private void commandQuitOut(Player player, String[] args)
|
||||
public void commandQuitOut(Player player, String[] args)
|
||||
{
|
||||
Manager.GetGame().QuitOut = !Manager.GetGame().QuitOut;
|
||||
|
||||
@ -924,7 +1039,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Double Jump
|
||||
private void commandDoubleJump(Player player, String[] args)
|
||||
public void commandDoubleJump(Player player, String[] args)
|
||||
{
|
||||
|
||||
if(!(Manager.GetGame() instanceof EventGame)) {
|
||||
@ -942,7 +1057,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Scoreboard
|
||||
private void commandScoreboard(Player player, String[] args)
|
||||
public void commandScoreboard(Player player, String[] args)
|
||||
{
|
||||
|
||||
if(!(Manager.GetGame() instanceof EventGame)) {
|
||||
@ -987,7 +1102,7 @@ public class EventModule extends MiniPlugin
|
||||
lineText += " ";
|
||||
}
|
||||
|
||||
((EventGame) Manager.GetGame()).getSideText()[line] = lineText;
|
||||
((EventGame) Manager.GetGame()).getSideText()[line] = ChatColor.translateAlternateColorCodes('&', lineText);
|
||||
|
||||
UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem(line+"") + " to " + F.elem(lineText) + "."));
|
||||
|
||||
@ -1016,7 +1131,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Whitelist
|
||||
private void commandWhitelist(Player player, String[] args)
|
||||
public void commandWhitelist(Player player, String[] args)
|
||||
{
|
||||
//On and Off
|
||||
if (args.length >= 2)
|
||||
@ -1056,7 +1171,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
|
||||
//Mob
|
||||
private void commandMob(Player caller, String[] args)
|
||||
public void commandMob(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
@ -1444,7 +1559,7 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void commandMobKill(Player caller, String[] args)
|
||||
public void commandMobKill(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 3)
|
||||
{
|
||||
@ -1490,7 +1605,17 @@ public class EventModule extends MiniPlugin
|
||||
UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed."));
|
||||
}
|
||||
|
||||
private void commandKit(Player caller, String[] args)
|
||||
public void commandBC(Player caller, String[] args)
|
||||
{
|
||||
String message = args[1];
|
||||
for(int e = 2; e < args.length; e++)
|
||||
message += " " + args[e];
|
||||
|
||||
String colored = ChatColor.translateAlternateColorCodes('&', message);
|
||||
Manager.GetGame().Announce(F.main("Event", colored), true);
|
||||
}
|
||||
|
||||
public void commandKit(Player caller, String[] args)
|
||||
{
|
||||
|
||||
if(!(Manager.GetGame() instanceof EventGame)) {
|
||||
@ -1533,7 +1658,7 @@ public class EventModule extends MiniPlugin
|
||||
commandHelp(caller);
|
||||
}
|
||||
|
||||
private void commandEffect(Player caller, String[] args)
|
||||
public void commandEffect(Player caller, String[] args, ArrayList<Player> players)
|
||||
{
|
||||
//Clear
|
||||
if (args.length >= 3 && args[2].equalsIgnoreCase("clear"))
|
||||
@ -1550,11 +1675,21 @@ public class EventModule extends MiniPlugin
|
||||
_potionEffectsMult.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(players == null)
|
||||
{
|
||||
targets = UtilPlayer.matchOnline(caller, args[1], true);
|
||||
if (targets.isEmpty())
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
targets = new LinkedList<>();
|
||||
for(Player player : players)
|
||||
targets.add(player);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : targets)
|
||||
{
|
||||
@ -1647,11 +1782,21 @@ public class EventModule extends MiniPlugin
|
||||
_potionEffectsMult.put(type, mult);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(players == null)
|
||||
{
|
||||
targets = UtilPlayer.matchOnline(caller, args[1], true);
|
||||
if (targets.isEmpty())
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
targets = new LinkedList<>();
|
||||
for(Player player : players)
|
||||
targets.add(player);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Apply
|
||||
PotionEffect effect = new PotionEffect(type, dur*20, mult);
|
||||
@ -1681,9 +1826,110 @@ public class EventModule extends MiniPlugin
|
||||
{
|
||||
for(PotionEffectType effect : _potionEffectsDuration.keySet())
|
||||
{
|
||||
if(_potionEffectsDuration.get(effect) < 0)
|
||||
continue;
|
||||
|
||||
player.addPotionEffect(new PotionEffect(effect, (int) (((_potionEffectsDuration.get(effect) - System.currentTimeMillis()) / 1000) * 20), _potionEffectsMult.get(effect)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void StackEntity(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (!Manager.GetGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.getRightClicked().getVehicle() != null)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Entity other = event.getRightClicked();
|
||||
|
||||
if(!_allowStacker && !_stacker.contains(player))
|
||||
return;
|
||||
|
||||
if (Manager.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (!Manager.GetGame().IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (Manager.getCosmeticManager().getGadgetManager().getActive(player, GadgetType.Morph) instanceof MorphBlock)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Stacker", "You cannot stack while using the Block Morph."));
|
||||
return;
|
||||
}
|
||||
|
||||
StackerEvent stackerEvent = new StackerEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(stackerEvent);
|
||||
if (stackerEvent.isCancelled())
|
||||
return;
|
||||
|
||||
//Effect
|
||||
event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 35);
|
||||
|
||||
//Stack
|
||||
player.setPassenger(other);
|
||||
|
||||
//Audio
|
||||
player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f);
|
||||
|
||||
//Inform
|
||||
if ((event.getRightClicked() instanceof Player))
|
||||
{
|
||||
UtilPlayer.message(other, F.main("Event", F.elem(Manager.GetGame().GetTeam(player).GetColor() + player.getName()) + " picked you up."));
|
||||
UtilPlayer.message(player, F.main("Event", "You picked up " + F.elem(Manager.GetGame().GetTeam(((Player) other)).GetColor() + ((Player) other).getName()) + "."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ThrowEntity(PlayerInteractEvent event)
|
||||
{
|
||||
if (!UtilEvent.isAction(event, ActionType.L))
|
||||
return;
|
||||
|
||||
Player thrower = event.getPlayer();
|
||||
|
||||
if (thrower.getVehicle() != null)
|
||||
return;
|
||||
|
||||
Entity throwee = thrower.getPassenger();
|
||||
if (throwee == null)
|
||||
return;
|
||||
|
||||
StackerEvent stackerEvent = new StackerEvent(thrower);
|
||||
Bukkit.getServer().getPluginManager().callEvent(stackerEvent);
|
||||
if (stackerEvent.isCancelled())
|
||||
return;
|
||||
|
||||
thrower.eject();
|
||||
|
||||
Entity throweeStack = throwee.getPassenger();
|
||||
if (throweeStack != null)
|
||||
{
|
||||
throwee.eject();
|
||||
throweeStack.leaveVehicle();
|
||||
|
||||
final Entity fThrower = thrower;
|
||||
final Entity fThroweeStack = throweeStack;
|
||||
|
||||
_tempStackShift.add(throweeStack);
|
||||
|
||||
getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
fThrower.setPassenger(fThroweeStack);
|
||||
_tempStackShift.remove(fThroweeStack);
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Player> getDamagePlayers()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager.AttackReason;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
|
@ -41,7 +41,7 @@ public class KitChicken extends EvoKit
|
||||
new Perk[]
|
||||
{
|
||||
new PerkConstructor("Egg Pouch", 2.0, 3, Material.EGG,
|
||||
"Egg Launcher Ammo", false), new PerkDoubleJumpEVO("Double Jump", 0.4, 0.9, false)
|
||||
"Egg Launcher Ammo", false), new PerkDoubleJumpEVO("Double Jump", 0.6, 0.9, false)
|
||||
}, EntityType.CHICKEN);
|
||||
}
|
||||
|
||||
|
@ -154,9 +154,6 @@ public class PerkSiesmicSlamEVO extends Perk
|
||||
|
||||
//Condition
|
||||
Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + "."));
|
||||
}
|
||||
|
||||
//Effect
|
||||
|
@ -4,17 +4,44 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitMachineGun;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitRifle;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.KitShotgun;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.stats.KillFastStatTracker;
|
||||
import nautilus.game.arcade.stats.LastStandStatTracker;
|
||||
import nautilus.game.arcade.stats.MedicStatTracker;
|
||||
import nautilus.game.arcade.stats.WinFastStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
@ -22,9 +49,11 @@ import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
@ -34,31 +63,6 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.games.paintball.kits.*;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.stats.KillFastStatTracker;
|
||||
import nautilus.game.arcade.stats.LastStandStatTracker;
|
||||
import nautilus.game.arcade.stats.MedicStatTracker;
|
||||
import nautilus.game.arcade.stats.WinFastStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker;
|
||||
|
||||
public class Paintball extends TeamGame
|
||||
{
|
||||
public static class ReviveEvent extends PlayerEvent
|
||||
@ -137,7 +141,6 @@ public class Paintball extends TeamGame
|
||||
this.GetTeamList().get(1).SetName("Nether");
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void ColorArmor(PlayerPrepareTeleportEvent event)
|
||||
{
|
||||
@ -160,6 +163,10 @@ public class Paintball extends TeamGame
|
||||
|
||||
@EventHandler
|
||||
public void Paint(ProjectileHitEvent event)
|
||||
{
|
||||
// Fixed projectile wool painting in waiting lobby.
|
||||
|
||||
if (IsLive() || GetState() == GameState.End)
|
||||
{
|
||||
if (event.getEntity() instanceof ThrownPotion)
|
||||
return;
|
||||
@ -180,12 +187,21 @@ public class Paintball extends TeamGame
|
||||
|
||||
if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8);
|
||||
else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_doubles.remove(event.getPlayer());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (_doubles.containsKey(player))
|
||||
{
|
||||
PlayerCopy copy = _doubles.get(player);
|
||||
copy.GetEntity().remove();
|
||||
_doubles.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -194,7 +210,9 @@ public class Paintball extends TeamGame
|
||||
if (event.GetDamageePlayer() == null)
|
||||
event.SetCancelled("Not Player");
|
||||
|
||||
if (event.GetProjectile() == null)
|
||||
// Fixed void damage being blocked from this check.
|
||||
|
||||
if (event.GetProjectile() == null && event.GetCause() != DamageCause.VOID)
|
||||
event.SetCancelled("No Projectile");
|
||||
}
|
||||
|
||||
@ -211,22 +229,27 @@ public class Paintball extends TeamGame
|
||||
return;
|
||||
|
||||
//Negate
|
||||
|
||||
event.AddMod("Negate", "Negate", -event.GetDamageInitial(), false);
|
||||
|
||||
event.AddMod("Paintball", "Paintball", 2, true);
|
||||
event.AddKnockback("Paintball", 2);
|
||||
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
if (damagee == null) return;
|
||||
if (damagee == null)
|
||||
return;
|
||||
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
if (damager == null) return;
|
||||
if (damager == null)
|
||||
return;
|
||||
|
||||
GameTeam damageeTeam = GetTeam(damagee);
|
||||
if (damageeTeam == null) return;
|
||||
if (damageeTeam == null)
|
||||
return;
|
||||
|
||||
GameTeam damagerTeam = GetTeam(damager);
|
||||
if (damagerTeam == null) return;
|
||||
if (damagerTeam == null)
|
||||
return;
|
||||
|
||||
if (damagerTeam.equals(damageeTeam))
|
||||
return;
|
||||
@ -259,6 +282,19 @@ public class Paintball extends TeamGame
|
||||
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 3f);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ArmorRemoveCancel(InventoryClickEvent event)
|
||||
{
|
||||
HumanEntity player = event.getWhoClicked();
|
||||
|
||||
// Fixed armor being taken off while spectating after being painted.
|
||||
|
||||
if (!IsAlive(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean Color(Player player, int amount)
|
||||
{
|
||||
//Get Non-Coloured
|
||||
|
@ -4,8 +4,10 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,8 +20,9 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.shop.page.ShopPageInventory;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.addons.compass.CompassAddon;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
@ -30,35 +33,46 @@ import nautilus.game.arcade.gui.spectatorMenu.button.SpectatorButton;
|
||||
* Created by shaun on 14-09-24.
|
||||
*/
|
||||
|
||||
public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
|
||||
public class SpectatorPage extends
|
||||
ShopPageInventory<CompassAddon, SpectatorShop>
|
||||
{
|
||||
private ArcadeManager _arcadeManager;
|
||||
private IButton[] _buttons;
|
||||
private ItemStack[] _items;
|
||||
|
||||
public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, SpectatorShop shop, CoreClientManager clientManager,
|
||||
public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager,
|
||||
SpectatorShop shop, CoreClientManager clientManager,
|
||||
DonationManager donationManager, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, "Spectator Menu", player);
|
||||
super(plugin, shop, clientManager, donationManager, "Spectator Menu",
|
||||
player);
|
||||
|
||||
_arcadeManager = arcadeManager;
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
protected void buildItems()
|
||||
{
|
||||
int playerCount = _arcadeManager.GetGame().GetPlayers(true).size();
|
||||
_buttons = new IButton[54];
|
||||
_items = new ItemStack[54];
|
||||
|
||||
List<GameTeam> teamList = _arcadeManager.GetGame().GetTeamList();
|
||||
|
||||
if (teamList.size() == 1 && playerCount < 28)
|
||||
buildSingleTeam(teamList.get(0), playerCount);
|
||||
else
|
||||
buildMultipleTeams(teamList, playerCount);
|
||||
int playerCount = _arcadeManager.GetGame().GetPlayers(true).size();
|
||||
|
||||
if (teamList.size() == 1 && playerCount < 28)
|
||||
{
|
||||
buildSingleTeam(teamList.get(0), playerCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
buildMultipleTeams(teamList, playerCount);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildSingleTeam(GameTeam team, int playerCount)
|
||||
{
|
||||
setItem(13, getTeamItem(team, playerCount));
|
||||
|
||||
ArrayList<Player> players = team.GetPlayers(true);
|
||||
|
||||
Collections.sort(players, new Comparator<Player>()
|
||||
@ -72,6 +86,11 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
|
||||
|
||||
});
|
||||
|
||||
_buttons = new IButton[19 + players.size()];
|
||||
_items = new ItemStack[_buttons.length];
|
||||
|
||||
_items[13] = getTeamItem(team, playerCount);
|
||||
|
||||
int slot = 19;
|
||||
|
||||
for (Player other : players)
|
||||
@ -79,41 +98,70 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
|
||||
addPlayerItem(slot, team, other);
|
||||
|
||||
if ((slot + 2) % 9 == 0)
|
||||
{
|
||||
_buttons = Arrays.copyOf(_buttons, _buttons.length + 3);
|
||||
_items = Arrays.copyOf(_items, _items.length + 3);
|
||||
|
||||
slot += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildMultipleTeams(List<GameTeam> teamList, int playerCount)
|
||||
{
|
||||
_buttons = new IButton[0];
|
||||
_items = new ItemStack[0];
|
||||
|
||||
int currentRow = 0;
|
||||
|
||||
Collections.sort(teamList, new Comparator<GameTeam>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(GameTeam o1, GameTeam o2)
|
||||
{
|
||||
int returns = o1.getDisplayName().compareToIgnoreCase(
|
||||
o2.getDisplayName());
|
||||
|
||||
if (returns == 0)
|
||||
{
|
||||
return Long.compare(o1.getCreatedTime(),
|
||||
o2.getCreatedTime());
|
||||
}
|
||||
|
||||
return returns;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (GameTeam team : teamList)
|
||||
{
|
||||
ArrayList<Player> teamPlayers = team.GetPlayers(true);
|
||||
int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0);
|
||||
|
||||
Collections.sort(teamPlayers, new Comparator<Player>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(Player o1, Player o2)
|
||||
{
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0);
|
||||
|
||||
_buttons = Arrays.copyOf(_buttons, _buttons.length
|
||||
+ (rowsNeeded * 9));
|
||||
_items = Arrays.copyOf(_items, _items.length + (rowsNeeded * 9));
|
||||
|
||||
for (int row = 0; row < rowsNeeded; row++)
|
||||
{
|
||||
int woolSlot = (row * 9) + (currentRow * 9);
|
||||
|
||||
// TODO Need to handle too many players in a better way
|
||||
if (woolSlot >= getSize())
|
||||
continue;
|
||||
|
||||
setItem(woolSlot, getTeamItem(team, teamPlayers.size()));
|
||||
_items[woolSlot] = getTeamItem(team, teamPlayers.size());
|
||||
|
||||
int playerIndex = row * 8;
|
||||
for (int i = 0; i < 8 && playerIndex < teamPlayers.size(); i++, playerIndex++)
|
||||
@ -121,36 +169,43 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
|
||||
Player other = teamPlayers.get(playerIndex);
|
||||
int slot = woolSlot + 1 + i;
|
||||
|
||||
// TODO Need to handle too many players in a better way
|
||||
if (slot >= getSize())
|
||||
continue;
|
||||
|
||||
addPlayerItem(slot, team, other);
|
||||
}
|
||||
}
|
||||
|
||||
// Add a line in between teams if the player count is low enough and there are less than 4 teams
|
||||
// Add a line in between teams if the player count is low enough and
|
||||
// there are less than 4 teams
|
||||
if (rowsNeeded == 1 && teamList.size() < 4 && playerCount <= 26)
|
||||
{
|
||||
currentRow += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentRow += rowsNeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayerItem(int slot, GameTeam team, Player other)
|
||||
{
|
||||
ItemStack playerItem = getPlayerItem(team, other);
|
||||
ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false);
|
||||
addButton(slot, shopItem, new SpectatorButton(_arcadeManager, getPlayer(), other));
|
||||
|
||||
ShopItem shopItem = new ShopItem(playerItem, other.getName(),
|
||||
other.getName(), 1, false, false);
|
||||
|
||||
_items[slot] = shopItem;
|
||||
_buttons[slot] = new SpectatorButton(_arcadeManager, getPlayer(), other);
|
||||
}
|
||||
|
||||
private ItemStack getTeamItem(GameTeam team, int playerCount)
|
||||
{
|
||||
ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, UtilColor.chatColorToWoolData(team.GetColor()));
|
||||
ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0,
|
||||
UtilColor.chatColorToWoolData(team.GetColor()));
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(team.GetFormattedName());
|
||||
meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + "Players Alive: " + C.cWhite + playerCount));
|
||||
meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow
|
||||
+ "Players Alive: " + C.cWhite + playerCount));
|
||||
item.setItemMeta(meta);
|
||||
|
||||
return item;
|
||||
@ -161,13 +216,17 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
|
||||
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
|
||||
|
||||
double distance = UtilMath.offset(getPlayer(), other);
|
||||
double heightDifference = other.getLocation().getY() - getPlayer().getLocation().getY();
|
||||
double heightDifference = other.getLocation().getY()
|
||||
- getPlayer().getLocation().getY();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite + _arcadeManager.GetGame().GetKit(other).GetName());
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite + UtilMath.trim(1, distance));
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite + UtilMath.trim(1, heightDifference));
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite
|
||||
+ _arcadeManager.GetGame().GetKit(other).GetName());
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite
|
||||
+ UtilMath.trim(1, distance));
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite
|
||||
+ UtilMath.trim(1, heightDifference));
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + C.Line + "Click to Spectate");
|
||||
SkullMeta skullMeta = ((SkullMeta) item.getItemMeta());
|
||||
@ -179,4 +238,16 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IButton[] getButtons()
|
||||
{
|
||||
return _buttons;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack[] getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
}
|
@ -952,7 +952,7 @@ public class GameFlagManager implements Listener
|
||||
Game game = Manager.GetGame();
|
||||
if (game == null) return;
|
||||
|
||||
if (!game.IsLive())
|
||||
if (!(game.IsLive() || game.GetState() == GameState.Prepare))
|
||||
return;
|
||||
|
||||
if (!game.TeleportsDisqualify)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user