Merge branch 'master' of ssh://dev1.mineplex.com:7999/min/mineplex
This commit is contained in:
commit
b64acf524c
@ -1,53 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="loc" default="default" basedir=".">
|
||||
<target name ="Dominate" description="Dominate">
|
||||
<jar jarfile="../bin/Dominate.jar">
|
||||
<fileset dir="../Nautilus.Game.Dominate/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Nautilus.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Minecraft.Game.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Nautilus.Game.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Nautilus.Game.Dominate">
|
||||
<include name="*.yml"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpcore-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-cache-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpmime-4.2.jar" />
|
||||
<zipfileset src="../Libraries/gson-2.2.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/Dominate.jar" todir="../../Testing/Dominate/plugins"/>
|
||||
</target>
|
||||
<target name ="Arcade" description="Arcade">
|
||||
<jar jarfile="../bin/Arcade.jar">
|
||||
<fileset dir="../Nautilus.Game.Arcade/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Nautilus.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
@ -61,7 +18,6 @@
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
|
||||
<fileset dir="../Nautilus.Game.Arcade">
|
||||
<include name="*.yml"/>
|
||||
</fileset>
|
||||
@ -81,9 +37,6 @@
|
||||
<fileset dir="../Mineplex.Hub/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Nautilus.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
@ -96,8 +49,6 @@
|
||||
<fileset dir="../Mineplex.Minecraft.Game.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
|
||||
<fileset dir="../Mineplex.Hub">
|
||||
<include name="*.yml"/>
|
||||
</fileset>
|
||||
@ -113,38 +64,6 @@
|
||||
</jar>
|
||||
<copy file="../bin/Hub.jar" todir="../../Testing/Hub/plugins"/>
|
||||
</target>
|
||||
<target name ="MineKart" description="MineKart">
|
||||
<jar jarfile="../bin/MineKart.jar">
|
||||
<fileset dir="../Nautilus.Game.MineKart/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Nautilus.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Minecraft.Game.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<fileset dir="../Nautilus.Game.MineKart">
|
||||
<include name="*.yml"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpcore-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-cache-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpmime-4.2.jar" />
|
||||
<zipfileset src="../Libraries/gson-2.2.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/MineKart.jar" todir="../../Testing/MineKart/plugins"/>
|
||||
</target>
|
||||
<target name ="MagicMC" description="MagicMC">
|
||||
<jar jarfile="../bin/MagicMC.jar">
|
||||
<fileset dir="../MagicMC/bin">
|
||||
|
Binary file not shown.
@ -47,6 +47,11 @@ public class UtilEnt
|
||||
return _nameMap;
|
||||
}
|
||||
|
||||
public static void silence(Entity entity, boolean silence)
|
||||
{
|
||||
((CraftEntity)entity).getHandle().Silent = silence;
|
||||
}
|
||||
|
||||
public static void ghost(Entity entity, boolean ghost, boolean invisible)
|
||||
{
|
||||
if (entity instanceof LivingEntity)
|
||||
|
@ -1,4 +1,4 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
@ -5,7 +5,6 @@
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/bukkit.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.ClassCombat"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.hub;
|
||||
|
||||
import mineplex.core.INautilusPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
@ -40,7 +41,6 @@ import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
import nautilus.minecraft.core.INautilusPlugin;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -23,6 +23,7 @@ import net.minecraft.server.v1_7_R1.EntityLiving;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftLivingEntity;
|
||||
@ -105,6 +106,20 @@ public class DamageManager extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void removeDemArrowsCrazyMan(EntityDamageEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
Projectile projectile = GetProjectile(event);
|
||||
|
||||
if (projectile instanceof Arrow)
|
||||
{
|
||||
projectile.teleport(new Location(projectile.getWorld(), 0, -200, 0));
|
||||
projectile.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
private boolean GoldPower(LivingEntity damager)
|
||||
{
|
||||
@ -259,6 +274,10 @@ public class DamageManager extends MiniPlugin
|
||||
//Effect
|
||||
event.GetDamageeEntity().playEffect(EntityEffect.HURT);
|
||||
|
||||
//Sticky Arrow
|
||||
if (event.GetCause() == DamageCause.PROJECTILE)
|
||||
((CraftLivingEntity)event.GetDamageeEntity()).getHandle().p(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().aZ() + 1);
|
||||
|
||||
//Knockback
|
||||
double knockback = event.GetDamage();
|
||||
if (knockback < 2) knockback = 2;
|
||||
|
@ -784,6 +784,7 @@ public abstract class Entity {
|
||||
}
|
||||
|
||||
public void makeSound(String s, float f, float f1) {
|
||||
if (!Silent)
|
||||
this.world.makeSound(this, s, f, f1);
|
||||
}
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/bukkit.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Dominate,PvP,CaptureThePig,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Dominate,PvP,CaptureThePig,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="Dominate,PvP,CaptureThePig,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Nautilus.Core}"/>
|
||||
</launchConfiguration>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Nautilus.Core</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/Nautilus.Core.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -1,12 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
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.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
@ -1,4 +0,0 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- WARNING: Eclipse auto-generated file.
|
||||
Any modifications will be overwritten.
|
||||
To include a user specific buildfile here, simply create one in the same
|
||||
directory with the processing instruction <?eclipse.ant.import?>
|
||||
as the first entry and export the buildfile again. -->
|
||||
<project basedir="." default="build" name="Nautilus.Core">
|
||||
<property environment="env"/>
|
||||
<property name="REPO_DIR" value="../../"/>
|
||||
<property name="ECLIPSE_HOME" value="../../../../../Program Files/eclipse"/>
|
||||
<property name="debuglevel" value="source,lines,vars"/>
|
||||
<property name="target" value="1.6"/>
|
||||
<property name="source" value="1.6"/>
|
||||
<path id="Nautilus.Core.classpath">
|
||||
<pathelement location="bin"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/httpcore-4.2.jar"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<path refid="Core.classpath"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/craftbukkit.jar"/>
|
||||
</path>
|
||||
<target name="init">
|
||||
<mkdir dir="bin"/>
|
||||
<copy includeemptydirs="false" todir="bin">
|
||||
<fileset dir="src">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="clean">
|
||||
<delete dir="bin"/>
|
||||
</target>
|
||||
<target depends="build-project" name="build"/>
|
||||
<target depends="init" name="build-project">
|
||||
<echo message="${ant.project.name}: ${ant.file}"/>
|
||||
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
|
||||
<src path="src"/>
|
||||
<classpath refid="Nautilus.Core.classpath"/>
|
||||
</javac>
|
||||
</target>
|
||||
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
|
||||
<copy todir="${ant.library.dir}">
|
||||
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
|
||||
</copy>
|
||||
<unzip dest="${ant.library.dir}">
|
||||
<patternset includes="jdtCompilerAdapter.jar"/>
|
||||
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
|
||||
</unzip>
|
||||
</target>
|
||||
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
<antcall target="build"/>
|
||||
</target>
|
||||
</project>
|
@ -1,16 +0,0 @@
|
||||
package nautilus.minecraft.core;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public interface INautilusPlugin
|
||||
{
|
||||
JavaPlugin GetPlugin();
|
||||
|
||||
String GetWebServerAddress();
|
||||
|
||||
Server GetRealServer();
|
||||
|
||||
PluginManager GetPluginManager();
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package nautilus.minecraft.core.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class AfkEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private String _playerName;
|
||||
|
||||
public AfkEvent(String playerName)
|
||||
{
|
||||
_playerName = playerName;
|
||||
}
|
||||
|
||||
public String GetPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
package nautilus.minecraft.core.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import nautilus.minecraft.core.event.AfkEvent;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AfkMonitor implements Listener, Runnable
|
||||
{
|
||||
private JavaPlugin _plugin;
|
||||
private HashMap<String, Long> _playerList;
|
||||
|
||||
public AfkMonitor(JavaPlugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_playerList = new HashMap<String, Long>();
|
||||
|
||||
_plugin.getServer().getPluginManager().registerEvents(this, _plugin);
|
||||
_plugin.getServer().getScheduler().scheduleSyncRepeatingTask(_plugin, this, 0L, 100L);
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
Iterator<Entry<String, Long>> afkIterator = _playerList.entrySet().iterator();
|
||||
|
||||
while (afkIterator.hasNext())
|
||||
{
|
||||
Entry<String, Long> entry = afkIterator.next();
|
||||
|
||||
long timeDiff = System.currentTimeMillis() - entry.getValue();
|
||||
|
||||
if (timeDiff >= 165000 && timeDiff < 180000)
|
||||
{
|
||||
Player player = _plugin.getServer().getPlayerExact(entry.getKey());
|
||||
|
||||
if (player != null && player.isOnline())
|
||||
{
|
||||
player.sendMessage(ChatColor.YELLOW + "You will be marked as AFK in a few seconds...");
|
||||
}
|
||||
}
|
||||
else if (timeDiff >= 180000)
|
||||
{
|
||||
_plugin.getServer().getPluginManager().callEvent(new AfkEvent(entry.getKey()));
|
||||
Player player = _plugin.getServer().getPlayerExact(entry.getKey());
|
||||
|
||||
if (player != null && player.isOnline())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "You have been marked as AFK.");
|
||||
}
|
||||
|
||||
afkIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
UpdatePlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerLeave(PlayerQuitEvent event)
|
||||
{
|
||||
UpdatePlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
UpdatePlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
UpdatePlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnInventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
UpdatePlayer((Player)event.getWhoClicked());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnInventoryOpen(InventoryOpenEvent event)
|
||||
{
|
||||
UpdatePlayer((Player)event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnInventoryClose(InventoryCloseEvent event)
|
||||
{
|
||||
UpdatePlayer((Player)event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
UpdatePlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
protected void UpdatePlayer(Player player)
|
||||
{
|
||||
_playerList.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
|
||||
public class GenericRunnable<T> implements Runnable
|
||||
{
|
||||
protected T t;
|
||||
|
||||
public GenericRunnable(T t)
|
||||
{
|
||||
this.t = t;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
|
||||
public class TimeStuff
|
||||
{
|
||||
public static String GetTimespanString(long millis)
|
||||
{
|
||||
int secs = (int)(millis / 1000);
|
||||
|
||||
if(secs < 60)
|
||||
return secs + " seconds";
|
||||
else
|
||||
return (secs / 60) + " minutes";
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Account;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class AccountToken
|
||||
{
|
||||
public long TotalPlayingTime;
|
||||
public long LastLogin;
|
||||
public int LoginCount;
|
||||
public Collection<String> IpAddresses;
|
||||
public Collection<String> MacAddresses;
|
||||
public Collection<String> IpAliases;
|
||||
public Collection<String> MacAliases;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Account;
|
||||
|
||||
public class ClientClanToken
|
||||
{
|
||||
public String Name;
|
||||
public String Role;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Account;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class ClientIgnoreToken
|
||||
{
|
||||
public Collection<String> Ignored;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Account;
|
||||
|
||||
public class ClientWikiToken
|
||||
{
|
||||
public String Name;
|
||||
public int ArticlesActive = 0;
|
||||
public int ArticlesDeprecated = 0;
|
||||
public int ArticlesDenied = 0;
|
||||
|
||||
public int VotesUp = 0;
|
||||
public int VotesDown = 0;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Account;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FishClientToken
|
||||
{
|
||||
public List<FishToken> FishTokens;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Account;
|
||||
|
||||
public class FishToken
|
||||
{
|
||||
public String Name;
|
||||
public double Size;
|
||||
public String Catcher;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Server;
|
||||
|
||||
public class FieldBlockToken
|
||||
{
|
||||
public String Server;
|
||||
|
||||
public String Location;
|
||||
|
||||
public int BlockId;
|
||||
|
||||
public byte BlockData;
|
||||
|
||||
public int EmptyId;
|
||||
|
||||
public byte EmptyData;
|
||||
|
||||
public int StockMax;
|
||||
|
||||
public double StockRegenTime;
|
||||
|
||||
public String Loot;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Server;
|
||||
|
||||
public class FieldMonsterToken
|
||||
{
|
||||
public String Name;
|
||||
|
||||
public String Server;
|
||||
|
||||
public String Type;
|
||||
|
||||
public int MobMax;
|
||||
|
||||
public double MobRate;
|
||||
|
||||
public String Centre;
|
||||
|
||||
public int Radius;
|
||||
|
||||
public int Height;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Server;
|
||||
|
||||
public class FieldOreToken
|
||||
{
|
||||
public String Server;
|
||||
|
||||
public String Location;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Server;
|
||||
|
||||
import mineplex.core.donation.repository.GameSalesPackageToken;
|
||||
|
||||
public class WeaponToken
|
||||
{
|
||||
public int WeaponId;
|
||||
|
||||
public String Name;
|
||||
|
||||
public GameSalesPackageToken SalesPackage;
|
||||
}
|
@ -6,7 +6,6 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core.CraftBukkit"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.ClassCombat"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
@ -8,6 +8,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import mineplex.core.INautilusPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antistack.AntiStack;
|
||||
@ -36,7 +37,6 @@ import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import nautilus.game.arcade.game.GameServerConfig;
|
||||
import nautilus.minecraft.core.INautilusPlugin;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -503,6 +503,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
((CraftPlayer)player).getHandle().spectating = false;
|
||||
((CraftPlayer)player).getHandle().l = true;
|
||||
|
||||
// Arrows go bye bye.
|
||||
((CraftPlayer)player).getHandle().p(0);
|
||||
|
||||
GetCondition().EndCondition(player, ConditionType.CLOAK, null);
|
||||
|
||||
HubClock(player);
|
||||
|
@ -128,6 +128,7 @@ public abstract class Kit implements Listener
|
||||
}
|
||||
|
||||
UtilEnt.Vegetate(entity);
|
||||
UtilEnt.silence(entity, true);
|
||||
UtilEnt.ghost(entity, true, false);
|
||||
|
||||
SpawnCustom(entity);
|
||||
|
@ -15,8 +15,8 @@ import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.WorldUtil;
|
||||
import mineplex.core.common.util.ZipUtil;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.minecraft.core.utils.ZipUtil;
|
||||
import net.minecraft.server.v1_7_R1.ChunkPreLoadEvent;
|
||||
|
||||
import org.bukkit.Difficulty;
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core.CraftBukkit"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.ClassCombat"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Dominate,CaptureThePig,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Dominate,CaptureThePig,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="Dominate,CaptureThePig,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Nautilus.Game.Core}"/>
|
||||
</launchConfiguration>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Nautilus.Game.Core</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/Nautilus.Game.Core.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -1,11 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
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.6
|
@ -1,99 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- WARNING: Eclipse auto-generated file.
|
||||
Any modifications will be overwritten.
|
||||
To include a user specific buildfile here, simply create one in the same
|
||||
directory with the processing instruction <?eclipse.ant.import?>
|
||||
as the first entry and export the buildfile again. -->
|
||||
<project basedir="." default="build" name="Nautilus.Game.Core">
|
||||
<property environment="env"/>
|
||||
<property name="REPO_DIR" value="../../"/>
|
||||
<property name="Nautilus.Game.CaptureThePig.location" value="../Nautilus.Game.CaptureThePig"/>
|
||||
<property name="Nautilus.Game.Dominate.location" value="../Nautilus.Game.Dominate"/>
|
||||
<property name="Nautilus.Main.location" value="../Nautilus.Main"/>
|
||||
<property name="ECLIPSE_HOME" value="../../../../../Program Files/eclipse"/>
|
||||
<property name="Nautilus.Core.CraftBukkit.location" value="../Nautilus.Core.CraftBukkit"/>
|
||||
<property name="Core.location" value="../Core"/>
|
||||
<property name="Nautilus.Core.location" value="../Nautilus.Core"/>
|
||||
<property name="debuglevel" value="source,lines,vars"/>
|
||||
<property name="target" value="1.6"/>
|
||||
<property name="source" value="1.6"/>
|
||||
<path id="Nautilus.Core.CraftBukkit.classpath">
|
||||
<pathelement location="${Nautilus.Core.CraftBukkit.location}/bin"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/jline-2.6.jar"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/craftbukkit.jar"/>
|
||||
</path>
|
||||
<path id="Core.classpath">
|
||||
<pathelement location="${Core.location}/bin"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/bukkit.jar"/>
|
||||
<path refid="Nautilus.Core.CraftBukkit.classpath"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/craftbukkit.jar"/>
|
||||
</path>
|
||||
<path id="Nautilus.Core.classpath">
|
||||
<pathelement location="${Nautilus.Core.location}/bin"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/httpcore-4.2.jar"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<path refid="Core.classpath"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/craftbukkit.jar"/>
|
||||
</path>
|
||||
<path id="Nautilus.Game.Core.classpath">
|
||||
<pathelement location="bin"/>
|
||||
<path refid="Nautilus.Core.classpath"/>
|
||||
<path refid="Core.classpath"/>
|
||||
<path refid="Nautilus.Core.CraftBukkit.classpath"/>
|
||||
<pathelement location="${REPO_DIR}/Plugins/Libraries/craftbukkit.jar"/>
|
||||
</path>
|
||||
<target name="init">
|
||||
<mkdir dir="bin"/>
|
||||
<copy includeemptydirs="false" todir="bin">
|
||||
<fileset dir="src">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="clean">
|
||||
<delete dir="bin"/>
|
||||
</target>
|
||||
<target depends="clean" name="cleanall">
|
||||
<ant antfile="Nautilus.Core.CraftBukkit.xml" dir="${Nautilus.Core.CraftBukkit.location}" inheritAll="false" target="clean"/>
|
||||
<ant antfile="Core.xml" dir="${Core.location}" inheritAll="false" target="clean"/>
|
||||
<ant antfile="Nautilus.Core.xml" dir="${Nautilus.Core.location}" inheritAll="false" target="clean"/>
|
||||
</target>
|
||||
<target depends="build-subprojects,build-project" name="build"/>
|
||||
<target name="build-subprojects">
|
||||
<ant antfile="Nautilus.Core.CraftBukkit.xml" dir="${Nautilus.Core.CraftBukkit.location}" inheritAll="false" target="build-project">
|
||||
<propertyset>
|
||||
<propertyref name="build.compiler"/>
|
||||
</propertyset>
|
||||
</ant>
|
||||
<ant antfile="Core.xml" dir="${Core.location}" inheritAll="false" target="build-project">
|
||||
<propertyset>
|
||||
<propertyref name="build.compiler"/>
|
||||
</propertyset>
|
||||
</ant>
|
||||
<ant antfile="Nautilus.Core.xml" dir="${Nautilus.Core.location}" inheritAll="false" target="build-project">
|
||||
<propertyset>
|
||||
<propertyref name="build.compiler"/>
|
||||
</propertyset>
|
||||
</ant>
|
||||
</target>
|
||||
<target depends="init" name="build-project">
|
||||
<echo message="${ant.project.name}: ${ant.file}"/>
|
||||
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
|
||||
<src path="src"/>
|
||||
<classpath refid="Nautilus.Game.Core.classpath"/>
|
||||
</javac>
|
||||
</target>
|
||||
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
|
||||
<copy todir="${ant.library.dir}">
|
||||
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
|
||||
</copy>
|
||||
<unzip dest="${ant.library.dir}">
|
||||
<patternset includes="jdtCompilerAdapter.jar"/>
|
||||
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
|
||||
</unzip>
|
||||
</target>
|
||||
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
<antcall target="build"/>
|
||||
</target>
|
||||
</project>
|
@ -1,171 +0,0 @@
|
||||
package nautilus.game.core;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antistack.AntiStack;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.blood.Blood;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.core.fakeEntity.FakeEntityManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.join.JoinQuit;
|
||||
import mineplex.core.memory.MemoryFix;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.server.Server;
|
||||
import mineplex.core.server.ServerListener;
|
||||
import mineplex.core.server.ServerTalker;
|
||||
import mineplex.core.spawn.Spawn;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatCustomBuildShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatPurchaseShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||
import mineplex.minecraft.game.core.IRelation;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.combat.*;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
import mineplex.minecraft.game.core.mechanics.PistonJump;
|
||||
import mineplex.minecraft.game.core.mechanics.Weapon;
|
||||
import nautilus.game.core.util.NullChunkGenerator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class GamePlugin extends JavaPlugin implements IRelation
|
||||
{
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
private BlockRestore _blockRestore;
|
||||
protected ClassManager ClassManager;
|
||||
protected CombatManager CombatManager;
|
||||
protected ConditionManager ConditionManager;
|
||||
protected CoreClientManager ClientManager;
|
||||
private Creature _creature;
|
||||
private DamageManager _damage;
|
||||
protected DonationManager DonationManager;
|
||||
protected PacketHandler PacketHandler;
|
||||
protected Energy Energy;
|
||||
private Fire _fire;
|
||||
protected NpcManager NpcManager;
|
||||
protected SkillFactory SkillManager;
|
||||
private Spawn _spawn;
|
||||
private Teleport _teleport;
|
||||
private ProjectileManager _throw;
|
||||
|
||||
private Location _spawnLocation;
|
||||
|
||||
protected ServerTalker HubConnection;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
try
|
||||
{
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
_spawnLocation = new Location(getServer().getWorlds().get(0), -7.5, 18.5, 24.5, 90, 0);
|
||||
|
||||
ClientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
|
||||
CommandCenter.Initialize(this, ClientManager);
|
||||
|
||||
FakeEntityManager.Initialize(this);
|
||||
ItemStackFactory.Initialize(this, true);
|
||||
Recharge.Initialize(this);
|
||||
|
||||
Updater updater = new Updater(this);
|
||||
_creature = new Creature(this);
|
||||
Energy = new Energy(this);
|
||||
DonationManager = new DonationManager(this, GetWebServerAddress());
|
||||
ConditionManager = new SkillConditionManager(this);
|
||||
CombatManager = new CombatManager(this);
|
||||
_blockRestore = new BlockRestore(this);
|
||||
_throw = new ProjectileManager(this);
|
||||
_spawn = new Spawn(this);
|
||||
_teleport = new Teleport(this, ClientManager, _spawn);
|
||||
NpcManager = new NpcManager(this, _creature);
|
||||
PacketHandler = new PacketHandler(this);
|
||||
_damage = new DamageManager(this, CombatManager, NpcManager, new DisguiseManager(this, PacketHandler));
|
||||
_fire = new Fire(this, ConditionManager, _damage);
|
||||
new Punish(this, GetWebServerAddress(), ClientManager);
|
||||
new ServerStatusManager(this, new LagMeter(this, ClientManager));
|
||||
|
||||
|
||||
SkillManager = new SkillFactory(this, _damage, this, CombatManager, ConditionManager, _throw, _blockRestore, _fire, new Movement(this), _teleport, Energy, GetWebServerAddress());
|
||||
ClassManager = new ClassManager(this, ClientManager, DonationManager, SkillManager, GetWebServerAddress());
|
||||
new ItemFactory(this, _blockRestore, ClassManager, ConditionManager, _damage, Energy, _fire, _throw, GetWebServerAddress(), new HashSet<String>());
|
||||
|
||||
new MessageManager(this, ClientManager);
|
||||
|
||||
new Blood(this);
|
||||
new JoinQuit();
|
||||
new Server();
|
||||
new AntiStack(this);
|
||||
new MemoryFix(this);
|
||||
new PistonJump(this);
|
||||
new Weapon(this, Energy);
|
||||
new FileUpdater(this, new Portal(this));
|
||||
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, updater, 1, 1);
|
||||
|
||||
ClassShopManager shopManager = new ClassShopManager(this, ClassManager, SkillManager, null);
|
||||
new ClassCombatShop(shopManager, ClientManager, DonationManager, "Select Class Here");
|
||||
new ClassCombatPurchaseShop(shopManager, ClientManager, DonationManager, "Skill Shop");
|
||||
new ClassCombatCustomBuildShop(shopManager, ClientManager, DonationManager, "Class Setup");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("Exception during startup. Restarting in 15 seconds.");
|
||||
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}, 300L);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String GetServerName();
|
||||
|
||||
public String GetWebServerAddress()
|
||||
{
|
||||
return getConfig().getString(WEB_CONFIG);
|
||||
}
|
||||
|
||||
public Location GetSpawnLocation()
|
||||
{
|
||||
return _spawnLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
||||
{
|
||||
return new NullChunkGenerator();
|
||||
}
|
||||
}
|
@ -1,263 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.common.util.WorldUtil;
|
||||
import net.minecraft.server.v1_7_R1.ChunkCoordinates;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Arena implements IArena
|
||||
{
|
||||
private Region _bounds;
|
||||
|
||||
protected String Name;
|
||||
protected World World;
|
||||
protected List<Region> Regions;
|
||||
protected Set<IArenaReloadedListener> Listeners = new HashSet<IArenaReloadedListener>();
|
||||
|
||||
protected int ChunkX;
|
||||
protected int ChunkZ;
|
||||
protected int MaxChunkX;
|
||||
protected int MaxChunkZ;
|
||||
protected int MinChunkX;
|
||||
protected int MinChunkZ;
|
||||
|
||||
protected int SpawnChunkX = -196;
|
||||
protected int SpawnChunkZ = -196;
|
||||
protected int SpawnMaxChunkX = 196;
|
||||
protected int SpawnMaxChunkZ = 196;
|
||||
|
||||
public Arena(String fileName)
|
||||
{
|
||||
Name = fileName;
|
||||
|
||||
Regions = new ArrayList<Region>();
|
||||
|
||||
World = WorldUtil.LoadWorld(WorldCreator.name(fileName).environment(org.bukkit.World.Environment.NORMAL).generateStructures(false));
|
||||
}
|
||||
|
||||
public String MapName;
|
||||
public Vector Center;
|
||||
public Vector Offset;
|
||||
|
||||
public boolean LoadArena(long maxMilliseconds)
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(((CraftWorld)World).getHandle().worldData.c(), ((CraftWorld)World).getHandle().worldData.d(), ((CraftWorld)World).getHandle().worldData.e());
|
||||
for (; SpawnChunkX <= SpawnMaxChunkX; SpawnChunkX += 16)
|
||||
{
|
||||
for (; SpawnChunkZ <= SpawnMaxChunkZ; SpawnChunkZ += 16)
|
||||
{
|
||||
if (System.currentTimeMillis() - startTime >= maxMilliseconds)
|
||||
return false;
|
||||
|
||||
((CraftWorld)World).getHandle().chunkProviderServer.getChunkAt(chunkcoordinates.x + SpawnChunkX >> 4, chunkcoordinates.z + SpawnChunkZ >> 4);
|
||||
}
|
||||
|
||||
SpawnChunkZ = -196;
|
||||
}
|
||||
|
||||
for (; ChunkX <= MaxChunkX; ChunkX++)
|
||||
{
|
||||
for (; ChunkZ <= MaxChunkZ; ChunkZ++)
|
||||
{
|
||||
if (System.currentTimeMillis() - startTime >= maxMilliseconds)
|
||||
return false;
|
||||
|
||||
World.loadChunk(ChunkX, ChunkZ, false);
|
||||
}
|
||||
|
||||
ChunkZ = MinChunkZ;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
_bounds = null;
|
||||
World = null;
|
||||
|
||||
Regions.clear();
|
||||
Regions = null;
|
||||
|
||||
Listeners.clear();
|
||||
Listeners = null;
|
||||
}
|
||||
|
||||
public World GetWorld()
|
||||
{
|
||||
return World;
|
||||
}
|
||||
|
||||
public Region GetBounds()
|
||||
{
|
||||
return _bounds;
|
||||
}
|
||||
|
||||
public void SetBounds(Region region)
|
||||
{
|
||||
_bounds = region;
|
||||
_bounds.SetPriority(-1);
|
||||
Regions.add(_bounds);
|
||||
|
||||
UpdateChunkVars(_bounds);
|
||||
Vector midPoint = _bounds.GetMidPoint();
|
||||
World.setSpawnLocation(midPoint.getBlockX(), midPoint.getBlockY(), midPoint.getBlockZ());
|
||||
}
|
||||
|
||||
public boolean IsInArena(Vector location)
|
||||
{
|
||||
return _bounds.Contains(location);
|
||||
}
|
||||
|
||||
public boolean IsChunkInArena(int x, int z)
|
||||
{
|
||||
return x >= MinChunkX && z >= MinChunkZ && x <= MaxChunkX && z <= MaxChunkZ;
|
||||
}
|
||||
|
||||
public boolean CanMove(String playerName, Vector from, Vector to)
|
||||
{
|
||||
boolean inRegions = false;
|
||||
boolean canMove = false;
|
||||
int priority = -999;
|
||||
|
||||
for (Region region : Regions)
|
||||
{
|
||||
if (region.Contains(to))
|
||||
{
|
||||
inRegions = true;
|
||||
}
|
||||
|
||||
if (region.GetPriority() > priority)
|
||||
{
|
||||
if (region.Contains(to))
|
||||
{
|
||||
canMove = region.CanEnter(playerName);
|
||||
priority = region.GetPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRegions)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return canMove;
|
||||
}
|
||||
|
||||
public boolean CanInteract(String playerName, Block block)
|
||||
{
|
||||
boolean inRegions = false;
|
||||
boolean canInteract = false;
|
||||
int priority = -999;
|
||||
|
||||
for (Region region : Regions)
|
||||
{
|
||||
if (region.Contains(block.getLocation().toVector()))
|
||||
{
|
||||
inRegions = true;
|
||||
}
|
||||
|
||||
if (region.GetPriority() > priority)
|
||||
{
|
||||
if (region.Contains(block.getLocation().toVector()))
|
||||
{
|
||||
canInteract = region.CanChangeBlocks(playerName);
|
||||
priority = region.GetPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRegions)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return canInteract;
|
||||
}
|
||||
|
||||
public void ClearRegionOwners()
|
||||
{
|
||||
for (Region region : Regions)
|
||||
{
|
||||
region.SetOwners(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearItems()
|
||||
{
|
||||
List<Entity> entities = World.getEntities();
|
||||
|
||||
for (Entity entity : entities)
|
||||
{
|
||||
if (entity instanceof Item)
|
||||
{
|
||||
if (_bounds.Contains(entity.getLocation().toVector()))
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateChunkVars(Region region)
|
||||
{
|
||||
if (region.GetMinimumPoint().getBlockX() >> 4 < ChunkX)
|
||||
ChunkX = region.GetMinimumPoint().getBlockX() >> 4;
|
||||
|
||||
if (region.GetMaximumPoint().getBlockX() >> 4 > MaxChunkX)
|
||||
MaxChunkX = region.GetMaximumPoint().getBlockX() >> 4;
|
||||
|
||||
if (region.GetMinimumPoint().getBlockZ() >> 4 < ChunkZ)
|
||||
ChunkZ = region.GetMinimumPoint().getBlockZ() >> 4;
|
||||
|
||||
if (region.GetMaximumPoint().getBlockZ() >> 4 > MaxChunkZ)
|
||||
MaxChunkZ = region.GetMaximumPoint().getBlockZ() >> 4;
|
||||
|
||||
MinChunkX = ChunkX;
|
||||
MinChunkZ = ChunkZ;
|
||||
}
|
||||
|
||||
|
||||
public void AddListener(IArenaReloadedListener listener)
|
||||
{
|
||||
Listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetMapName(String value)
|
||||
{
|
||||
MapName = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetCenter(Vector center)
|
||||
{
|
||||
Center = center;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetOffset(Vector offset)
|
||||
{
|
||||
Offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return MapName;
|
||||
}
|
||||
}
|
@ -1,207 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.FileUtil;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import nautilus.minecraft.core.utils.ZipUtil;
|
||||
import net.minecraft.server.v1_7_R1.ChunkPreLoadEvent;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ArenaManager<ArenaType extends IArena> implements Listener, Runnable
|
||||
{
|
||||
private JavaPlugin _plugin;
|
||||
private String _gamemode;
|
||||
private IArenaParser<ArenaType> _arenaParser;
|
||||
private HashMap<ArenaType, String> _arenaWorldFolderMap;
|
||||
private List<String> _availableArenas;
|
||||
private HashMap<ArenaType, Callback<ArenaType>> _loadingArenas;
|
||||
private HashMap<ArenaType, Callback<ArenaType>> _delayArenaCallback;
|
||||
|
||||
private Random _random;
|
||||
private int _arenaCount;
|
||||
|
||||
private HashMap<String, ArenaType> _chunkWorldRegionMap;
|
||||
|
||||
public ArenaManager(JavaPlugin plugin, String gamemode, IArenaParser<ArenaType> arenaParser)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_gamemode = gamemode;
|
||||
_arenaParser = arenaParser;
|
||||
_availableArenas = new ArrayList<String>();
|
||||
_loadingArenas = new HashMap<ArenaType, Callback<ArenaType>>();
|
||||
_delayArenaCallback = new HashMap<ArenaType, Callback<ArenaType>>();
|
||||
_chunkWorldRegionMap = new HashMap<String, ArenaType>();
|
||||
_arenaWorldFolderMap = new HashMap<ArenaType, String>();
|
||||
_random = new Random();
|
||||
|
||||
_plugin.getServer().getPluginManager().registerEvents(this, _plugin);
|
||||
_plugin.getServer().getScheduler().scheduleSyncRepeatingTask(_plugin, this, 1, 1);
|
||||
PopulateAvailableArenas();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnChunkLoad(ChunkPreLoadEvent event)
|
||||
{
|
||||
String key = event.GetWorld().getName();
|
||||
|
||||
if (_chunkWorldRegionMap.containsKey(key))
|
||||
{
|
||||
ArenaType arena = _chunkWorldRegionMap.get(key);
|
||||
|
||||
if (!arena.IsChunkInArena(event.GetX(), event.GetZ()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveArena(ArenaType arena)
|
||||
{
|
||||
if (_arenaWorldFolderMap.containsKey(arena))
|
||||
{
|
||||
long arenaRemovalTime = System.currentTimeMillis();
|
||||
MapUtil.UnloadWorld(_plugin, arena.GetWorld());
|
||||
MapUtil.ClearWorldReferences(arena.GetWorld().getName());
|
||||
|
||||
FileUtil.DeleteFolder(arena.GetWorld().getWorldFolder());
|
||||
|
||||
_arenaWorldFolderMap.remove(arena);
|
||||
_chunkWorldRegionMap.remove(arena.GetWorld().getName());
|
||||
|
||||
System.out.println("Removed world '" + arena.GetWorld().getName() + "' in " + (System.currentTimeMillis() - arenaRemovalTime) + "ms");
|
||||
arena.Deactivate();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("not in arenaWorldFolderMap");
|
||||
}
|
||||
}
|
||||
|
||||
public void GetNextArena(Callback<ArenaType> callback)
|
||||
{
|
||||
String key = _availableArenas.get(_random.nextInt(_availableArenas.size()));
|
||||
|
||||
String directory = _plugin.getDataFolder().getAbsoluteFile().getParentFile().getParentFile() + File.separator;
|
||||
String name = directory + _arenaCount;
|
||||
|
||||
new File(name).mkdir();
|
||||
|
||||
// TODO Queue/Optimize unzip - currently 50ms on production server.
|
||||
ZipUtil.UnzipToDirectory(key, name);
|
||||
|
||||
ArenaType arena = null;
|
||||
|
||||
try
|
||||
{
|
||||
FileReader configReader = new FileReader(new File(name + File.separator + "arena.config").getAbsolutePath());
|
||||
arena = _arenaParser.Parse(name, configReader);
|
||||
configReader.close();
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
_arenaWorldFolderMap.put(arena, key);
|
||||
|
||||
_loadingArenas.put(arena, callback);
|
||||
_arenaCount++;
|
||||
}
|
||||
|
||||
private void PopulateAvailableArenas()
|
||||
{
|
||||
if(!_plugin.getDataFolder().exists())
|
||||
{
|
||||
_plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File dominateArenaDir = new File(_plugin.getDataFolder().getAbsoluteFile().getParentFile().getParentFile().getParentFile() + File.separator + "Arenas" + File.separator + _gamemode);
|
||||
|
||||
if(!dominateArenaDir.getAbsoluteFile().getParentFile().exists())
|
||||
{
|
||||
dominateArenaDir.getAbsoluteFile().getParentFile().mkdir();
|
||||
}
|
||||
|
||||
if(!dominateArenaDir.exists())
|
||||
{
|
||||
dominateArenaDir.mkdir();
|
||||
}
|
||||
|
||||
FilenameFilter statsFilter = new FilenameFilter()
|
||||
{
|
||||
public boolean accept(File paramFile, String paramString)
|
||||
{
|
||||
if (paramString.endsWith("zip"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
for (File f : dominateArenaDir.listFiles(statsFilter))
|
||||
{
|
||||
_availableArenas.add(f.getAbsolutePath());
|
||||
System.out.println("Adding arena zip file : " + f);
|
||||
}
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
Iterator<ArenaType> arenaIterator = _delayArenaCallback.keySet().iterator();
|
||||
|
||||
while (arenaIterator.hasNext())
|
||||
{
|
||||
ArenaType arena = arenaIterator.next();
|
||||
|
||||
_delayArenaCallback.get(arena).run(arena);
|
||||
arenaIterator.remove();
|
||||
}
|
||||
|
||||
long endTime = System.currentTimeMillis() + 25;
|
||||
long timeLeft;
|
||||
arenaIterator = _loadingArenas.keySet().iterator();
|
||||
|
||||
while (arenaIterator.hasNext())
|
||||
{
|
||||
ArenaType arena = arenaIterator.next();
|
||||
|
||||
timeLeft = endTime - System.currentTimeMillis();
|
||||
if (timeLeft > 0)
|
||||
{
|
||||
if (arena.LoadArena(timeLeft))
|
||||
{
|
||||
_chunkWorldRegionMap.put(arena.GetWorld().getName(), arena);
|
||||
_delayArenaCallback.put(arena, _loadingArenas.get(arena));
|
||||
arenaIterator.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean HasAvailableArena()
|
||||
{
|
||||
return _availableArenas.size() > 0;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public interface IArena
|
||||
{
|
||||
World GetWorld();
|
||||
Region GetBounds();
|
||||
boolean IsInArena(Vector location);
|
||||
boolean IsChunkInArena(int x, int z);
|
||||
boolean CanMove(String playerName, Vector from, Vector to);
|
||||
boolean CanInteract(String playerName, Block withBlock);
|
||||
|
||||
boolean LoadArena(long maxMilliseconds);
|
||||
void Deactivate();
|
||||
String GetName();
|
||||
|
||||
void SetMapName(String value);
|
||||
void SetBounds(Region boundsRegion);
|
||||
void SetCenter(Vector center);
|
||||
void SetOffset(Vector offset);
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
import java.io.FileReader;
|
||||
|
||||
public interface IArenaParser<ArenaType extends IArena>
|
||||
{
|
||||
ArenaType Parse(String fileName, FileReader fileReader);
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
|
||||
public interface IArenaReloadedListener
|
||||
{
|
||||
void ArenaReloaded(Arena arena);
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public interface ITeamArena extends IArena
|
||||
{
|
||||
void AddRedSpawnPoint(Vector spawnPoint, float yaw);
|
||||
List<Location> GetRedSpawnPoints();
|
||||
|
||||
void AddBlueSpawnPoint(Vector spawnPoint, float yaw);
|
||||
List<Location> GetBlueSpawnPoints();
|
||||
|
||||
void SetBlueSpawnRoom(Region region);
|
||||
void SetRedSpawnRoom(Region region);
|
||||
|
||||
Region GetBlueSpawnRoom();
|
||||
Region GetRedSpawnRoom();
|
||||
|
||||
void AddBlueGameShopPoint(Vector spawnPoint, float yaw);
|
||||
List<Location> GetBlueShopPoints();
|
||||
|
||||
void AddRedGameShopPoint(Vector spawnPoint, float yaw);
|
||||
List<Location> GetRedShopPoints();
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Region
|
||||
{
|
||||
private String _name;
|
||||
private transient Vector _pointOne;
|
||||
private transient Vector _pointTwo;
|
||||
|
||||
private List<String> _owners;
|
||||
|
||||
private Boolean _blockPassage = false;
|
||||
private Boolean _blockChange = true;
|
||||
|
||||
private int _priority;
|
||||
|
||||
private int _minX;
|
||||
private int _minY;
|
||||
private int _minZ;
|
||||
|
||||
private int _maxX;
|
||||
private int _maxY;
|
||||
private int _maxZ;
|
||||
|
||||
public Region(String name, Vector pointOne, Vector pointTwo)
|
||||
{
|
||||
_name = name;
|
||||
_pointOne = pointOne;
|
||||
_pointTwo = pointTwo;
|
||||
_priority = 0;
|
||||
_owners = new ArrayList<String>();
|
||||
|
||||
UpdateMinMax();
|
||||
}
|
||||
|
||||
public Vector GetMaximumPoint()
|
||||
{
|
||||
return new Vector(_maxX, _maxY, _maxZ);
|
||||
}
|
||||
|
||||
public void AdjustRegion(Vector vector)
|
||||
{
|
||||
_minX += vector.getBlockX();
|
||||
_minY += vector.getBlockY();
|
||||
_minZ += vector.getBlockZ();
|
||||
|
||||
_maxX += vector.getBlockX();
|
||||
_maxY += vector.getBlockY();
|
||||
_maxZ += vector.getBlockZ();
|
||||
}
|
||||
|
||||
public Vector GetMinimumPoint()
|
||||
{
|
||||
return new Vector(_minX, _minY, _minZ);
|
||||
}
|
||||
|
||||
public Vector GetMidPoint()
|
||||
{
|
||||
return new Vector((_maxX - _minX)/2 + _minX, (_maxY - _minY)/2 + _minY, (_maxZ - _minZ)/2 + _minZ);
|
||||
}
|
||||
|
||||
public void SetPriority(int priority)
|
||||
{
|
||||
_priority = priority;
|
||||
}
|
||||
|
||||
public int GetPriority()
|
||||
{
|
||||
return _priority;
|
||||
}
|
||||
|
||||
public Boolean Contains(Vector v)
|
||||
{
|
||||
return v.getBlockX() >= _minX && v.getBlockX() <= _maxX
|
||||
&& v.getBlockY() >= _minY && v.getBlockY() <= _maxY
|
||||
&& v.getBlockZ() >= _minZ && v.getBlockZ() <= _maxZ;
|
||||
}
|
||||
|
||||
public void AddOwner(String name)
|
||||
{
|
||||
if (!_owners.contains(name.toLowerCase()))
|
||||
{
|
||||
_owners.add(name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveOwner(String name)
|
||||
{
|
||||
_owners.remove(name.toLowerCase());
|
||||
}
|
||||
|
||||
public void SetOwners(List<String> owners)
|
||||
{
|
||||
_owners = owners;
|
||||
|
||||
for (String ownerName : _owners)
|
||||
{
|
||||
ownerName = ownerName.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEnter(Boolean canEnter)
|
||||
{
|
||||
_blockPassage = !canEnter;
|
||||
}
|
||||
|
||||
public void SetChangeBlocks(Boolean canChangeBlocks)
|
||||
{
|
||||
_blockChange = !canChangeBlocks;
|
||||
}
|
||||
|
||||
public Boolean CanEnter(String playerName)
|
||||
{
|
||||
if (_blockPassage)
|
||||
{
|
||||
if (!_owners.contains(playerName.toLowerCase()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean CanChangeBlocks(String playerName)
|
||||
{
|
||||
if (_blockChange)
|
||||
{
|
||||
if (!_owners.contains(playerName.toLowerCase()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
private void UpdateMinMax()
|
||||
{
|
||||
_minX = Math.min(_pointOne.getBlockX(), _pointTwo.getBlockX());
|
||||
_minY = Math.min(_pointOne.getBlockY(), _pointTwo.getBlockY());
|
||||
_minZ = Math.min(_pointOne.getBlockZ(), _pointTwo.getBlockZ());
|
||||
|
||||
_maxX = Math.max(_pointOne.getBlockX(), _pointTwo.getBlockX());
|
||||
_maxY = Math.max(_pointOne.getBlockY(), _pointTwo.getBlockY());
|
||||
_maxZ = Math.max(_pointOne.getBlockZ(), _pointTwo.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Maximum point: " + GetMaximumPoint() + " Minimum point: " + GetMinimumPoint();
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class RegionManager
|
||||
{
|
||||
private String _dataFolder;
|
||||
private Map<String, Region> _regions;
|
||||
|
||||
public RegionManager(String dataFolder)
|
||||
{
|
||||
_dataFolder = dataFolder;
|
||||
_regions = new HashMap<String, Region>();
|
||||
}
|
||||
|
||||
public Region GetRegion(String name)
|
||||
{
|
||||
return _regions.get(name);
|
||||
}
|
||||
|
||||
public Boolean Contains(String name)
|
||||
{
|
||||
return _regions.containsKey(name);
|
||||
}
|
||||
|
||||
public List<Region> GetApplicableRegions(Vector v)
|
||||
{
|
||||
List<Region> applicableRegions = new ArrayList<Region>();
|
||||
|
||||
for (Region region : _regions.values())
|
||||
{
|
||||
if (region.Contains(v))
|
||||
{
|
||||
applicableRegions.add(region);
|
||||
}
|
||||
}
|
||||
|
||||
return applicableRegions;
|
||||
}
|
||||
|
||||
void SaveRegion(Region region)
|
||||
{
|
||||
FileOutputStream fOS = null;
|
||||
ObjectOutputStream obOut = null;
|
||||
|
||||
File f = new File(_dataFolder + "/regions/" + region.GetName() + ".region");
|
||||
File dir = new File(_dataFolder + "/regions/");
|
||||
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkdir();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (f.exists())
|
||||
{
|
||||
f.delete();
|
||||
}
|
||||
|
||||
if (!f.exists())
|
||||
{
|
||||
f.createNewFile();
|
||||
}
|
||||
|
||||
fOS = new FileOutputStream(f);
|
||||
obOut = new ObjectOutputStream(fOS);
|
||||
obOut.writeObject(region);
|
||||
obOut.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("[ERROR] Failed to saving region - " + region.GetName() + " : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateNewRegion(Player player, String name, Vector pointOne, Vector pointTwo)
|
||||
{
|
||||
if (_regions.get(name) != null)
|
||||
{
|
||||
player.sendMessage(ChatColor.DARK_RED + "That game region already exists. Use update command.");
|
||||
return;
|
||||
}
|
||||
|
||||
//CreateRegion(new Region(this, name, pointOne, pointTwo));
|
||||
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Successfully create game region - " + name + ".");
|
||||
}
|
||||
|
||||
public void UpdateRegion(Player player, String name, Vector pointOne, Vector pointTwo)
|
||||
{
|
||||
if (_regions.get(name) == null)
|
||||
{
|
||||
player.sendMessage(ChatColor.DARK_RED + "That game region does not exist. Use create command.");
|
||||
return;
|
||||
}
|
||||
|
||||
_regions.remove(name);
|
||||
|
||||
//CreateRegion(new Region(this, name, pointOne, pointTwo));
|
||||
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Successfully updated game region - " + name + ".");
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
package nautilus.game.core.arena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TeamArena extends Arena implements ITeamArena
|
||||
{
|
||||
protected Region BlueSpawnRoom;
|
||||
protected Region RedSpawnRoom;
|
||||
protected List<Location> RedSpawnPoints;
|
||||
protected List<Location> BlueSpawnPoints;
|
||||
|
||||
protected List<Location> RedShopPoints;
|
||||
protected List<Location> BlueShopPoints;
|
||||
|
||||
public TeamArena(String name)
|
||||
{
|
||||
super(name);
|
||||
|
||||
RedSpawnPoints = new ArrayList<Location>();
|
||||
BlueSpawnPoints = new ArrayList<Location>();
|
||||
|
||||
RedShopPoints = new ArrayList<Location>();
|
||||
BlueShopPoints = new ArrayList<Location>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Deactivate()
|
||||
{
|
||||
super.Deactivate();
|
||||
|
||||
RedSpawnPoints.clear();
|
||||
RedSpawnPoints = null;
|
||||
|
||||
BlueSpawnPoints.clear();
|
||||
BlueSpawnPoints = null;
|
||||
|
||||
RedShopPoints.clear();
|
||||
RedShopPoints = null;
|
||||
|
||||
BlueShopPoints.clear();
|
||||
BlueShopPoints = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsInArena(Vector location)
|
||||
{
|
||||
return super.IsInArena(location) || RedSpawnRoom.Contains(location) || BlueSpawnRoom.Contains(location);
|
||||
}
|
||||
|
||||
public void AddRedSpawnPoint(Vector spawnPoint, float yaw)
|
||||
{
|
||||
RedSpawnPoints.add(new Location(World, spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), yaw, 0f));
|
||||
}
|
||||
|
||||
public List<Location> GetRedSpawnPoints()
|
||||
{
|
||||
return RedSpawnPoints;
|
||||
}
|
||||
|
||||
public void AddBlueSpawnPoint(Vector spawnPoint, float yaw)
|
||||
{
|
||||
BlueSpawnPoints.add(new Location(World, spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), yaw, 0f));
|
||||
}
|
||||
|
||||
public List<Location> GetBlueSpawnPoints()
|
||||
{
|
||||
return BlueSpawnPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetBlueSpawnRoom(Region region)
|
||||
{
|
||||
Regions.add(region);
|
||||
BlueSpawnRoom = region;
|
||||
|
||||
UpdateChunkVars(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetRedSpawnRoom(Region region)
|
||||
{
|
||||
Regions.add(region);
|
||||
RedSpawnRoom = region;
|
||||
|
||||
UpdateChunkVars(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region GetBlueSpawnRoom()
|
||||
{
|
||||
return BlueSpawnRoom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region GetRedSpawnRoom()
|
||||
{
|
||||
return RedSpawnRoom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddBlueGameShopPoint(Vector spawnPoint, float yaw)
|
||||
{
|
||||
BlueShopPoints.add(new Location(World, spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), yaw, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddRedGameShopPoint(Vector spawnPoint, float yaw)
|
||||
{
|
||||
RedShopPoints.add(new Location(World, spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), yaw, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Location> GetBlueShopPoints()
|
||||
{
|
||||
return BlueShopPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Location> GetRedShopPoints()
|
||||
{
|
||||
return RedShopPoints;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
|
||||
public class BlueShopPoints<ArenaType extends ITeamArena> extends PropertyBase<ArenaType>
|
||||
{
|
||||
public BlueShopPoints()
|
||||
{
|
||||
super("blueshoppoints");
|
||||
}
|
||||
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
for (String vector : value.split(","))
|
||||
{
|
||||
arena.AddBlueGameShopPoint(ParseVector(vector.trim()), Float.parseFloat(vector.trim().split(" ")[3]) * 90);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
|
||||
public class BlueSpawnPoints<ArenaType extends ITeamArena> extends PropertyBase<ArenaType>
|
||||
{
|
||||
public BlueSpawnPoints()
|
||||
{
|
||||
super("bluespawnpoints");
|
||||
}
|
||||
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
for (String vector : value.split(","))
|
||||
{
|
||||
arena.AddBlueSpawnPoint(ParseVector(vector.trim()), Float.parseFloat(vector.trim().split(" ")[3]) * 90);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.arena.Region;
|
||||
|
||||
public class BlueSpawnRoom<ArenaType extends ITeamArena> extends RegionPropertyBase<ArenaType>
|
||||
{
|
||||
public BlueSpawnRoom()
|
||||
{
|
||||
super("bluespawnroom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
arena.SetBlueSpawnRoom(ParseRegion(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean Parse(ArenaType arena, Location start, Location stop)
|
||||
{
|
||||
arena.SetBlueSpawnRoom(new Region("bluespawnroom", start.toVector(), stop.toVector()));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
import nautilus.game.core.arena.Region;
|
||||
|
||||
public class BorderProperty<ArenaType extends IArena> extends RegionPropertyBase<ArenaType>
|
||||
{
|
||||
public BorderProperty()
|
||||
{
|
||||
super("border");
|
||||
}
|
||||
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
Region boundsRegion = ParseRegion(value);
|
||||
|
||||
arena.SetBounds(boundsRegion);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
|
||||
public class Center<ArenaType extends IArena> extends PropertyBase<ArenaType>
|
||||
{
|
||||
public Center()
|
||||
{
|
||||
super("center");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
arena.SetCenter(ParseVector(value));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
|
||||
public interface IProperty<ArenaType extends IArena>
|
||||
{
|
||||
String GetName();
|
||||
|
||||
boolean Parse(ArenaType arena, String value);
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
|
||||
public class MapName<ArenaType extends IArena> extends PropertyBase<ArenaType>
|
||||
{
|
||||
public MapName()
|
||||
{
|
||||
super("mapname");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
arena.SetMapName(value);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
|
||||
public class Offset<ArenaType extends IArena> extends PropertyBase<ArenaType>
|
||||
{
|
||||
public Offset()
|
||||
{
|
||||
super("offset");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
arena.SetOffset(ParseVector(value));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public abstract class PropertyBase<ArenaType extends IArena> implements IProperty<ArenaType>
|
||||
{
|
||||
protected String Name;
|
||||
|
||||
public PropertyBase(String name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
protected Vector ParseVector(String vectorString)
|
||||
{
|
||||
Vector vector = new Vector();
|
||||
|
||||
String [] parts = vectorString.split(" ");
|
||||
|
||||
vector.setX(Double.parseDouble(parts[0]));
|
||||
vector.setY(Double.parseDouble(parts[1]));
|
||||
vector.setZ(Double.parseDouble(parts[2]));
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
protected Vector ParseVector(Player player)
|
||||
{
|
||||
return player.getLocation().toVector();
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
|
||||
public class RedShopPoints<ArenaType extends ITeamArena> extends PropertyBase<ArenaType>
|
||||
{
|
||||
public RedShopPoints()
|
||||
{
|
||||
super("redshoppoints");
|
||||
}
|
||||
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
for (String vector : value.split(","))
|
||||
{
|
||||
arena.AddRedGameShopPoint(ParseVector(vector.trim()), Float.parseFloat(vector.trim().split(" ")[3]) * 90);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
|
||||
public class RedSpawnPoints<ArenaType extends ITeamArena> extends PropertyBase<ArenaType>
|
||||
{
|
||||
public RedSpawnPoints()
|
||||
{
|
||||
super("redspawnpoints");
|
||||
}
|
||||
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
for (String vector : value.split(","))
|
||||
{
|
||||
arena.AddRedSpawnPoint(ParseVector(vector.trim()), Float.parseFloat(vector.trim().split(" ")[3]) * 90);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.arena.Region;
|
||||
|
||||
public class RedSpawnRoom<ArenaType extends ITeamArena> extends RegionPropertyBase<ArenaType>
|
||||
{
|
||||
public RedSpawnRoom()
|
||||
{
|
||||
super("redspawnroom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean Parse(ArenaType arena, String value)
|
||||
{
|
||||
arena.SetRedSpawnRoom(ParseRegion(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean Parse(ArenaType arena, Location start, Location stop)
|
||||
{
|
||||
arena.SetRedSpawnRoom(new Region("redspawnroom", start.toVector(), stop.toVector()));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package nautilus.game.core.arena.property;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
import nautilus.game.core.arena.Region;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public abstract class RegionPropertyBase<ArenaType extends IArena> extends PropertyBase<ArenaType>
|
||||
{
|
||||
public RegionPropertyBase(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected Region ParseRegion(String value)
|
||||
{
|
||||
String [] parts = value.split(",");
|
||||
|
||||
Vector pointOne = ParseVector(parts[0].trim());
|
||||
Vector pointTwo = ParseVector(parts[1].trim());
|
||||
|
||||
return new Region(parts.length == 3 ? parts[2].trim() : Name, pointOne, pointTwo);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,55 +0,0 @@
|
||||
package nautilus.game.core.engine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
|
||||
public class GameScheduler<GameType extends IGame<?,?>>
|
||||
{
|
||||
private List<GameType> _schedule;
|
||||
|
||||
public GameScheduler()
|
||||
{
|
||||
_schedule = new ArrayList<GameType>();
|
||||
}
|
||||
|
||||
public List<GameType> GetGames()
|
||||
{
|
||||
return _schedule;
|
||||
}
|
||||
|
||||
public boolean ContainsGame(GameType game)
|
||||
{
|
||||
return _schedule.contains(game);
|
||||
}
|
||||
|
||||
public GameType ScheduleNewGame(GameType game)
|
||||
{
|
||||
_schedule.add(game);
|
||||
|
||||
return game;
|
||||
}
|
||||
|
||||
public void RemoveGame(GameType game)
|
||||
{
|
||||
_schedule.remove(game);
|
||||
}
|
||||
|
||||
public void CleanEmptyGames()
|
||||
{
|
||||
Iterator<GameType> gameIterator = _schedule.iterator();
|
||||
|
||||
while (gameIterator.hasNext())
|
||||
{
|
||||
GameType game = gameIterator.next();
|
||||
|
||||
if (game.GetPlayers().isEmpty())
|
||||
{
|
||||
game.Deactivate();
|
||||
gameIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package nautilus.game.core.engine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface IGameEngine<GameType extends IGame<ArenaType, PlayerType>, ArenaType extends IArena, PlayerType extends IGamePlayer>
|
||||
{
|
||||
boolean IsPlayerInGame(Player player);
|
||||
boolean IsPlayerInActiveGame(Player player);
|
||||
boolean IsPlayerInActiveGame(String playerName);
|
||||
|
||||
GameType GetGameForPlayer(Player player);
|
||||
GameType GetGameForPlayer(String playerName);
|
||||
|
||||
void RemovePlayerFromGame(Player player);
|
||||
void RemovePlayerFromGame(Player player, boolean quit);
|
||||
|
||||
String GetGameType();
|
||||
|
||||
List<GameType> GetGames();
|
||||
|
||||
GameType ScheduleNewGame();
|
||||
|
||||
boolean AddPlayerToGame(Player player, boolean notify);
|
||||
List<GameType> GetActiveGames();
|
||||
void AddSpectatorToGame(GameType game, Player player, Location location);
|
||||
void RemoveSpectatorFromGame(Player player, boolean quit);
|
||||
boolean IsSpectatorInActiveGame(Player player);
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package nautilus.game.core.engine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import nautilus.game.core.arena.Region;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
public interface ITeam<PlayerType extends ITeamGamePlayer<?>>
|
||||
{
|
||||
TeamType GetTeamType();
|
||||
|
||||
void AddPlayer(PlayerType player);
|
||||
|
||||
void RemovePlayer(PlayerType player);
|
||||
|
||||
List<PlayerType> GetPlayers();
|
||||
|
||||
void AddPoint();
|
||||
void AddPoints(int points);
|
||||
|
||||
void SetScore(int scores);
|
||||
int GetScore();
|
||||
|
||||
void ClearPlayers();
|
||||
|
||||
void SetSpawnRoom(Region spawnRoom);
|
||||
|
||||
boolean IsInSpawnRoom(Location location);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package nautilus.game.core.engine;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.game.ITeamGame;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
public interface ITeamGameEngine<GameType extends ITeamGame<ArenaType, PlayerType, PlayerTeamType>, ArenaType extends ITeamArena, PlayerTeamType extends ITeam<PlayerType>, PlayerType extends ITeamGamePlayer<PlayerTeamType>> extends IGameEngine<GameType, ArenaType, PlayerType>
|
||||
{
|
||||
}
|
@ -1,691 +0,0 @@
|
||||
package nautilus.game.core.engine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.server.ServerTalker;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.energy.*;
|
||||
import mineplex.core.npc.*;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||
import mineplex.minecraft.game.core.condition.*;
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.arena.ArenaManager;
|
||||
import nautilus.game.core.events.GamePlayerAttackedPlayerEvent;
|
||||
import nautilus.game.core.events.GamePlayerDeathEvent;
|
||||
import nautilus.game.core.events.team.TeamGameFinishedEvent;
|
||||
import nautilus.game.core.game.ITeamGame;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
import nautilus.game.core.scoreboard.ITeamScoreHandler;
|
||||
import nautilus.minecraft.core.utils.GenericRunnable;
|
||||
import net.minecraft.server.v1_7_R1.Packet;
|
||||
import net.minecraft.server.v1_7_R1.Packet201PlayerInfo;
|
||||
|
||||
public abstract class TeamGameEngine<GameType extends ITeamGame<ArenaType, PlayerType, PlayerTeamType>, ScoreHandlerType extends ITeamScoreHandler<PlayerType, PlayerTeamType>, ArenaType extends ITeamArena, PlayerTeamType extends ITeam<PlayerType>, PlayerType extends ITeamGamePlayer<PlayerTeamType>> extends GameEngine<GameType, ScoreHandlerType, ArenaType, PlayerType> implements ITeamGameEngine<GameType, ArenaType, PlayerTeamType, PlayerType>
|
||||
{
|
||||
private int _gameQueueTickValue;
|
||||
|
||||
protected int TeamSize = 1;
|
||||
protected PacketHandler PacketHandler;
|
||||
|
||||
protected boolean BroadcastQueueJoinMessage = true;
|
||||
protected int MinQueuePlayersToStart = 4;
|
||||
protected int TimeToStart = 2;
|
||||
|
||||
protected NpcManager NpcManager;
|
||||
|
||||
private List<Entity> _shopEntities = new ArrayList<Entity>();
|
||||
private NautHashMap<Player, Scoreboard> _scoreboardMap = new NautHashMap<Player, Scoreboard>();
|
||||
|
||||
public TeamGameEngine(JavaPlugin plugin, ServerTalker hubConnection, CoreClientManager clientManager, DonationManager donationManager, ClassManager classManager,
|
||||
ConditionManager conditionManager, Energy energy, NpcManager npcManager, PacketHandler packetHandler, ArenaManager<ArenaType> arenaManager, ScoreHandlerType scoreHandler, World world, Location spawnLocation)
|
||||
{
|
||||
super(plugin, hubConnection, clientManager, donationManager, classManager, conditionManager, energy, arenaManager, scoreHandler, world, spawnLocation);
|
||||
|
||||
NpcManager = npcManager;
|
||||
PacketHandler = packetHandler;
|
||||
}
|
||||
|
||||
protected void TryToActivateGames()
|
||||
{
|
||||
Iterator<GameType> gameIterator = Scheduler.GetGames().iterator();
|
||||
|
||||
while (gameIterator.hasNext())
|
||||
{
|
||||
GameType game = gameIterator.next();
|
||||
|
||||
if (game.GetPlayers().size() == TeamSize * 2 && ArenaManager.HasAvailableArena() && (MaxGames == -1 || ActiveGames.size() < MaxGames))
|
||||
{
|
||||
SetupGame(game);
|
||||
gameIterator.remove();
|
||||
_gameQueueTickValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean IsGameFull(GameType gameType)
|
||||
{
|
||||
return gameType.GetPlayers().size() >= TeamSize * 2;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void PlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
CreateScoreboard(event.getPlayer());
|
||||
}
|
||||
|
||||
private void CreateScoreboard(Player player)
|
||||
{
|
||||
_scoreboardMap.put(player, Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
|
||||
Scoreboard scoreboard = _scoreboardMap.get(player);
|
||||
Objective objective = scoreboard.registerNewObjective("§l" + "Score", "dummy");
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
|
||||
for (Rank rank : Rank.values())
|
||||
{
|
||||
if (rank == Rank.ALL)
|
||||
{
|
||||
scoreboard.registerNewTeam(rank.Name).setPrefix("");
|
||||
}
|
||||
else
|
||||
{
|
||||
scoreboard.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, false) + ChatColor.RESET + " " + ChatColor.WHITE);
|
||||
}
|
||||
|
||||
if (rank == Rank.ALL)
|
||||
{
|
||||
scoreboard.registerNewTeam(rank.Name + "red".toUpperCase()).setPrefix(ChatColor.RED + "");
|
||||
scoreboard.registerNewTeam(rank.Name + "blue".toUpperCase()).setPrefix(ChatColor.BLUE + "");
|
||||
}
|
||||
else
|
||||
{
|
||||
scoreboard.registerNewTeam(rank.Name + "red".toUpperCase()).setPrefix(rank.GetTag(true, false) + ChatColor.RESET + " " + ChatColor.RED);
|
||||
scoreboard.registerNewTeam(rank.Name + "blue".toUpperCase()).setPrefix(rank.GetTag(true, false) + ChatColor.RESET + " " + ChatColor.BLUE);
|
||||
}
|
||||
}
|
||||
|
||||
player.setScoreboard(scoreboard);
|
||||
|
||||
for (Player otherPlayer : UtilServer.getPlayers())
|
||||
{
|
||||
AddPlayerToScoreboards(otherPlayer, GetGameForPlayer(otherPlayer).IsActive() ? GetGameForPlayer(otherPlayer).GetPlayer(otherPlayer).GetTeam().GetTeamType().name() : null);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<Scoreboard> GetScoreboards()
|
||||
{
|
||||
return _scoreboardMap.values();
|
||||
}
|
||||
|
||||
public void AddPlayerToScoreboards(Player player, String teamName)
|
||||
{
|
||||
for (Scoreboard scoreboard : GetScoreboards())
|
||||
{
|
||||
for (Team team : scoreboard.getTeams())
|
||||
team.removePlayer(player);
|
||||
}
|
||||
|
||||
if (teamName == null)
|
||||
teamName = "";
|
||||
|
||||
for (Scoreboard scoreboard : GetScoreboards())
|
||||
{
|
||||
scoreboard.getTeam(ClientManager.Get(player).GetRank().Name + teamName).addPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void UpdateGameScoreboards(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
for (GameType activeGame : ActiveGames)
|
||||
{
|
||||
for (PlayerType player : activeGame.GetPlayers())
|
||||
{
|
||||
Scoreboard scoreboard = _scoreboardMap.get(player.GetPlayer());
|
||||
|
||||
Objective objective = scoreboard.getObjective("§l" + "Score");
|
||||
objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BLUE + "Blue")).setScore(activeGame.GetBlueTeam().GetScore());
|
||||
objective.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Red")).setScore(activeGame.GetRedTeam().GetScore());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateStartTimer(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.MIN_01)
|
||||
return;
|
||||
|
||||
if (Scheduler.GetGames().size() > 0)
|
||||
{
|
||||
GameType game = Scheduler.GetGames().get(Scheduler.GetGames().size() - 1);
|
||||
int players = game.GetPlayers().size();
|
||||
|
||||
if (players < TeamSize * 2 && players >= MinQueuePlayersToStart)
|
||||
{
|
||||
_gameQueueTickValue++;
|
||||
|
||||
if (_gameQueueTickValue > TimeToStart)
|
||||
{
|
||||
TeamSize = players/2;
|
||||
TryToActivateGames();
|
||||
}
|
||||
else if (BroadcastQueueJoinMessage)
|
||||
{
|
||||
for (Player gameplayer : game.GetBlueTeam().GetPlayers().get(0).GetPlayer().getWorld().getPlayers())
|
||||
{
|
||||
String minuteMessage = (3 - _gameQueueTickValue) == 1 ? "minute" : "minutes";
|
||||
gameplayer.sendMessage(F.main("Play Queue", "Game will start in " + (3 - _gameQueueTickValue) + " " + minuteMessage + "!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGamePlayerDeath(GamePlayerDeathEvent<GameType, PlayerType> event)
|
||||
{
|
||||
GameType game = event.GetGame();
|
||||
|
||||
//Color Names
|
||||
try
|
||||
{
|
||||
if (event.GetPlayer().GetTeam().GetTeamType() == TeamType.RED)
|
||||
event.GetLog().SetKilledColor(C.cRed + "");
|
||||
else
|
||||
event.GetLog().SetKilledColor(C.cBlue + "");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("[SEVERE] TeamGameEngine.onGamePlayerDeath : Exception Setting Killed Color : " + e.getMessage());
|
||||
|
||||
for (StackTraceElement trace : e.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (event.GetLog().GetKiller() != null)
|
||||
{
|
||||
PlayerType killer = game.GetPlayer(event.GetLog().GetKiller().GetName());
|
||||
|
||||
if (killer.GetTeam().GetTeamType() == TeamType.RED)
|
||||
event.GetLog().SetKillerColor(C.cRed + "");
|
||||
else
|
||||
event.GetLog().SetKillerColor(C.cBlue + "");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("[SEVERE] TeamGameEngine.onGamePlayerDeath : Exception Setting Killed Color : " + e.getMessage());
|
||||
|
||||
for (StackTraceElement trace : e.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
|
||||
ScoreHandler.RewardForDeath(event.GetPlayer());
|
||||
|
||||
boolean first = true;
|
||||
|
||||
try
|
||||
{
|
||||
for (CombatComponent source : event.GetLog().GetAttackers())
|
||||
{
|
||||
if (source == null || !source.IsPlayer())
|
||||
continue;
|
||||
|
||||
PlayerType attacker = game.GetPlayer(source.GetName());
|
||||
|
||||
if (attacker == null)
|
||||
continue;
|
||||
|
||||
if (first)
|
||||
{
|
||||
if (attacker.GetTeam() == event.GetPlayer().GetTeam())
|
||||
{
|
||||
ScoreHandler.RewardForTeamKill(attacker, event.GetPlayer());
|
||||
}
|
||||
else
|
||||
{
|
||||
ScoreHandler.RewardForKill(attacker, event.GetPlayer(), event.GetLog().GetAssists());
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScoreHandler.RewardForAssist(attacker, event.GetPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("[SEVERE] TeamGameEngine.onGamePlayerDeath : Exception Handleing team kill/kill/assist : " + ex.getMessage());
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
|
||||
game.StartRespawnFor(event.GetPlayer());
|
||||
}
|
||||
|
||||
private void AddPlayerToTeam(GameType game, Player player, PlayerTeamType team, Boolean notify)
|
||||
{
|
||||
PlayerType gamePlayer = game.AddPlayerToGame(player);
|
||||
PlayerGameMap.put(gamePlayer.getName(), game);
|
||||
|
||||
team.AddPlayer(gamePlayer);
|
||||
|
||||
if (ActiveGames.contains(game))
|
||||
{
|
||||
player.eject();
|
||||
|
||||
if (player.isInsideVehicle())
|
||||
player.leaveVehicle();
|
||||
|
||||
for (Player otherPlayer : Plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player != otherPlayer)
|
||||
{
|
||||
player.showPlayer(otherPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
game.ActivatePlayer(gamePlayer);
|
||||
}
|
||||
|
||||
TryToActivateGames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean AddPlayerToGame(Player player, boolean notify)
|
||||
{
|
||||
GameType game = GetNextOpenGame();
|
||||
|
||||
if (game == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int redTeamSize = game.GetRedTeam().GetPlayers().size();
|
||||
int blueTeamSize = game.GetBlueTeam().GetPlayers().size();
|
||||
|
||||
if (blueTeamSize < redTeamSize)
|
||||
{
|
||||
AddPlayerToBlueTeam(game, player);
|
||||
player.playSound(player.getLocation(), Sound.ZOMBIE_METAL, .5F, .5F);
|
||||
}
|
||||
else if (redTeamSize < blueTeamSize)
|
||||
{
|
||||
AddPlayerToRedTeam(game, player);
|
||||
player.playSound(player.getLocation(), Sound.ZOMBIE_METAL, .5F, .5F);
|
||||
}
|
||||
else if (blueTeamSize < TeamSize)
|
||||
{
|
||||
AddPlayerToBlueTeam(game, player);
|
||||
player.playSound(player.getLocation(), Sound.ZOMBIE_METAL, .5F, .5F);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Error neither blue nor red have < " + TeamSize + " players and " + player.getName() + " shouldn't be assigned to this game.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (game.GetPlayers().size() < TeamSize*2 && BroadcastQueueJoinMessage)
|
||||
{
|
||||
for (Player gameplayer : player.getWorld().getPlayers())
|
||||
{
|
||||
gameplayer.sendMessage(ChatColor.BLUE + "Play Queue> " + ChatColor.GRAY + "Only " + (TeamSize*2 - game.GetPlayers().size()) + " more players needed to start game!");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddPlayerToRedTeam(GameType game, Player player)
|
||||
{
|
||||
AddPlayerToRedTeam(game, player, true);
|
||||
}
|
||||
|
||||
public void AddPlayerToBlueTeam(GameType game, Player player)
|
||||
{
|
||||
AddPlayerToBlueTeam(game, player, true);
|
||||
}
|
||||
|
||||
public void AddPlayerToRedTeam(GameType game, Player player, Boolean notify)
|
||||
{
|
||||
AddPlayerToTeam(game, player, game.GetRedTeam(), notify);
|
||||
}
|
||||
|
||||
public void AddPlayerToBlueTeam(GameType game, Player player, Boolean notify)
|
||||
{
|
||||
AddPlayerToTeam(game, player, game.GetBlueTeam(), notify);
|
||||
}
|
||||
|
||||
public void SetupGame(final GameType game)
|
||||
{
|
||||
GamesInSetup.add(game);
|
||||
|
||||
for (PlayerType gamePlayer : game.GetPlayers())
|
||||
{
|
||||
if (IsSpectatorInActiveGame(gamePlayer.GetPlayer()))
|
||||
RemoveSpectatorFromGame(gamePlayer.GetPlayer(), true);
|
||||
|
||||
gamePlayer.sendMessage(ChatColor.BLUE + "Dominate>" + ChatColor.GRAY + " Preparing map...");
|
||||
}
|
||||
|
||||
ArenaManager.GetNextArena(new Callback<ArenaType>()
|
||||
{
|
||||
public void run(ArenaType arena)
|
||||
{
|
||||
ActivateGame(game, arena);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void RemovePlayerFromGame(GameType game, PlayerType player, boolean quit)
|
||||
{
|
||||
super.RemovePlayerFromGame(game, player, quit);
|
||||
|
||||
if (!ActiveGames.contains(game) && game != null && game.GetRedTeam() != null && game.GetBlueTeam() != null)
|
||||
{
|
||||
int redTeamSize = game.GetRedTeam().GetPlayers().size();
|
||||
int blueTeamSize = game.GetBlueTeam().GetPlayers().size();
|
||||
|
||||
if (redTeamSize - blueTeamSize > 1)
|
||||
{
|
||||
PlayerType movingPlayer = game.GetRedTeam().GetPlayers().get(0);
|
||||
|
||||
game.GetRedTeam().RemovePlayer(movingPlayer);
|
||||
game.GetBlueTeam().AddPlayer(movingPlayer);
|
||||
}
|
||||
else if (blueTeamSize - redTeamSize > 1)
|
||||
{
|
||||
PlayerType movingPlayer = game.GetBlueTeam().GetPlayers().get(0);
|
||||
|
||||
game.GetBlueTeam().RemovePlayer(movingPlayer);
|
||||
game.GetRedTeam().AddPlayer(movingPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ActivateGame(GameType game, ArenaType arena)
|
||||
{
|
||||
GamesInSetup.remove(game);
|
||||
ActiveGames.add(game);
|
||||
|
||||
List<Packet> removeListPacket = new ArrayList<Packet>();
|
||||
|
||||
for (PlayerType player : game.GetPlayers())
|
||||
{
|
||||
if (player.isOnline())
|
||||
{
|
||||
player.GetPlayer().eject();
|
||||
|
||||
if (player.GetPlayer().isInsideVehicle())
|
||||
player.GetPlayer().leaveVehicle();
|
||||
|
||||
removeListPacket.add(new Packet201PlayerInfo(player.getName(), false, -9999));
|
||||
}
|
||||
}
|
||||
|
||||
for (PlayerType player : game.GetPlayers())
|
||||
{
|
||||
if (player.isOnline())
|
||||
{
|
||||
for (Packet packet : removeListPacket)
|
||||
{
|
||||
((CraftPlayer)player.GetPlayer()).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
AddPlayerToScoreboards(player.GetPlayer(), player.GetTeam().GetTeamType().name());
|
||||
}
|
||||
}
|
||||
|
||||
removeListPacket.clear();
|
||||
|
||||
game.Activate(arena);
|
||||
|
||||
for (Location location : arena.GetBlueShopPoints())
|
||||
{
|
||||
_shopEntities.add(NpcManager.AddNpc(EntityType.ZOMBIE, 0, ChatColor.BLUE + "Select Class Here", location));
|
||||
}
|
||||
|
||||
for (Location location : arena.GetRedShopPoints())
|
||||
{
|
||||
_shopEntities.add(NpcManager.AddNpc(EntityType.ZOMBIE, 0, ChatColor.RED + "Select Class Here", location));
|
||||
}
|
||||
|
||||
for (PlayerType player : game.GetPlayers())
|
||||
{
|
||||
for (Player otherPlayer : Plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player.GetPlayer() != otherPlayer)
|
||||
{
|
||||
player.GetPlayer().showPlayer(otherPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void StopGame(GameType game)
|
||||
{
|
||||
for (Entity entity : _shopEntities)
|
||||
{
|
||||
NpcManager.DeleteNpc(entity);
|
||||
}
|
||||
|
||||
super.StopGame(game);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onGameFinished(final TeamGameFinishedEvent<GameType, PlayerTeamType, PlayerType> event)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Plugin, new GenericRunnable<GameType>(event.GetGame())
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (PlayerType player : event.GetGame().GetPlayers())
|
||||
{
|
||||
Portal.SendPlayerToServer(player.GetPlayer(), "Lobby");
|
||||
}
|
||||
}
|
||||
}, 100L);
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Plugin, new GenericRunnable<GameType>(event.GetGame())
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
StopGame(t);
|
||||
}
|
||||
}, 300L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGamePlayerAttackedPlayerEvent(GamePlayerAttackedPlayerEvent<GameType, PlayerType> event)
|
||||
{
|
||||
PlayerType attacker = event.GetAttacker();
|
||||
PlayerType victim = event.GetVictim();
|
||||
|
||||
if (attacker.GetTeam() == victim.GetTeam())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (victim.IsDead() || attacker.IsDead())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void HandleChat(final AsyncPlayerChatEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
final Player sender = event.getPlayer();
|
||||
String message = event.getMessage();
|
||||
|
||||
if (message.length() < 1)
|
||||
return;
|
||||
|
||||
if (!IsPlayerInActiveGame(sender))
|
||||
{
|
||||
Iterator<Player> recipientIterator = event.getRecipients().iterator();
|
||||
|
||||
while(recipientIterator.hasNext())
|
||||
{
|
||||
Player otherPlayer = recipientIterator.next();
|
||||
|
||||
if (IsPlayerInActiveGame(otherPlayer))
|
||||
recipientIterator.remove();
|
||||
}
|
||||
|
||||
StringBuilder playerNameBuilder = new StringBuilder();
|
||||
|
||||
if (ClientManager.Get(sender.getName()) != null)
|
||||
{
|
||||
CoreClient client = ClientManager.Get(sender.getName());
|
||||
|
||||
if (client.GetRank().Has(Rank.OWNER))
|
||||
{
|
||||
playerNameBuilder.append(ChatColor.DARK_RED);
|
||||
}
|
||||
else if (client.GetRank().Has(Rank.MODERATOR))
|
||||
{
|
||||
playerNameBuilder.append(ChatColor.RED);
|
||||
}
|
||||
else if (client.GetRank().Has(Rank.ULTRA))
|
||||
{
|
||||
playerNameBuilder.append(ChatColor.GOLD);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerNameBuilder.append(ChatColor.YELLOW);
|
||||
}
|
||||
}
|
||||
|
||||
event.setFormat(playerNameBuilder.toString() + "%1$s " + C.cWhite + "%2$s");
|
||||
}
|
||||
else
|
||||
{
|
||||
GameType senderGame = GetGameForPlayer(sender);
|
||||
TeamType senderTeamType = senderGame.GetPlayer(sender).GetTeam().GetTeamType();
|
||||
|
||||
String teamColor = senderTeamType == TeamType.RED ? C.cRed : C.cBlue;
|
||||
|
||||
boolean globalMessage = false;
|
||||
if (message.charAt(0) == '!')
|
||||
{
|
||||
globalMessage = true;
|
||||
event.setMessage(message.substring(1, message.length()));
|
||||
event.setFormat(C.cDGray + "@" + C.cDAqua + "All" + " " + teamColor + "%1$s " + C.cWhite + "%2$s");
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setFormat(C.cDGray + "@" + C.cDAqua + "Team" + " " + teamColor + "%1$s " + C.cWhite + "%2$s");
|
||||
}
|
||||
|
||||
Iterator<Player> recipientIterator = event.getRecipients().iterator();
|
||||
|
||||
while (recipientIterator.hasNext())
|
||||
{
|
||||
Player receiver = recipientIterator.next();
|
||||
|
||||
if (!IsPlayerInActiveGame(receiver) || GetGameForPlayer(receiver) != senderGame)
|
||||
{
|
||||
recipientIterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!globalMessage && senderTeamType != senderGame.GetPlayer(receiver).GetTeam().GetTeamType())
|
||||
recipientIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanHurt(Player a, Player b)
|
||||
{
|
||||
if (IsPlayerInActiveGame(b) && IsPlayerInActiveGame(a))
|
||||
{
|
||||
GameType game = GetGameForPlayer(b);
|
||||
|
||||
if (game.HasStarted())
|
||||
{
|
||||
PlayerType victim = game.GetPlayer(b);
|
||||
PlayerType attacker = game.GetPlayer(a);
|
||||
|
||||
if (victim.IsDead() || victim.IsSpectating())
|
||||
return false;
|
||||
|
||||
if (attacker == null || attacker.GetTeam() == victim.GetTeam())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor GetColorOfFor(String other, Player player)
|
||||
{
|
||||
ChatColor prefixColor = super.GetColorOfFor(other, player);
|
||||
|
||||
if (IsPlayerInActiveGame(other))
|
||||
{
|
||||
PlayerTeamType playerTeam = GetGameForPlayer(other).GetPlayer(other).GetTeam();
|
||||
|
||||
prefixColor = (playerTeam.GetTeamType() == TeamType.RED ? ChatColor.RED : ChatColor.BLUE);
|
||||
}
|
||||
|
||||
return prefixColor;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package nautilus.game.core.engine;
|
||||
|
||||
public enum TeamType
|
||||
{
|
||||
RED,
|
||||
BLUE
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class GameActivatedEvent<GameType extends IGame<?, ? extends IGamePlayer>> extends GameEvent<GameType>
|
||||
{
|
||||
public GameActivatedEvent(GameType game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class GameDeactivatedEvent<GameType extends IGame<?, ? extends IGamePlayer>> extends GameEvent<GameType>
|
||||
{
|
||||
public GameDeactivatedEvent(GameType game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class GameEvent<GameType extends IGame<? extends IArena, ? extends IGamePlayer>> extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private GameType _game;
|
||||
|
||||
public GameEvent(GameType game)
|
||||
{
|
||||
_game = game;
|
||||
}
|
||||
|
||||
public GameType GetGame()
|
||||
{
|
||||
return _game;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class GameFinishedEvent<GameType extends IGame<?, ? extends IGamePlayer>> extends GameEvent<GameType>
|
||||
{
|
||||
public GameFinishedEvent(GameType game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class GamePlayerAfkEvent<GameType extends IGame<?, PlayerType>, PlayerType extends IGamePlayer> extends GameEvent<GameType>
|
||||
{
|
||||
private PlayerType _player;
|
||||
|
||||
public GamePlayerAfkEvent(GameType game, PlayerType player)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public PlayerType GetPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class GamePlayerAttackedPlayerEvent<GameType extends IGame<?, PlayerType>, PlayerType extends IGamePlayer> extends GameEvent<GameType> implements Cancellable
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean _cancelled = false;
|
||||
private PlayerType _attacker;
|
||||
private PlayerType _victim;
|
||||
|
||||
public GamePlayerAttackedPlayerEvent(GameType game, PlayerType attacker, PlayerType victim)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_attacker = attacker;
|
||||
_victim = victim;
|
||||
}
|
||||
|
||||
public PlayerType GetAttacker()
|
||||
{
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public PlayerType GetVictim()
|
||||
{
|
||||
return _victim;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel)
|
||||
{
|
||||
_cancelled = cancel;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.minecraft.game.core.combat.CombatLog;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GamePlayerDeathEvent<GameType extends IGame<?, PlayerType>, PlayerType extends IGamePlayer> extends GameEvent<GameType>
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private PlayerType _player;
|
||||
private PlayerType _killer;
|
||||
private List<PlayerType> _assistants;
|
||||
private List<ItemStack> _drops;
|
||||
private CombatLog _log;
|
||||
|
||||
public GamePlayerDeathEvent(GameType game, PlayerType player, PlayerType killer, List<PlayerType> assistants, List<ItemStack> drops, CombatDeathEvent combatDeath)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_player = player;
|
||||
_killer = killer;
|
||||
_assistants = assistants;
|
||||
_drops = drops;
|
||||
_log = combatDeath.GetLog();
|
||||
}
|
||||
|
||||
public PlayerType GetPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public PlayerType GetKiller()
|
||||
{
|
||||
return _killer;
|
||||
}
|
||||
|
||||
public List<PlayerType> GetAssistants()
|
||||
{
|
||||
return _assistants;
|
||||
}
|
||||
|
||||
public List<ItemStack> GetDrops()
|
||||
{
|
||||
return _drops;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public CombatLog GetLog()
|
||||
{
|
||||
return _log;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class GamePlayerJoinedEvent<GameType extends IGame<?, PlayerType>, PlayerType extends IGamePlayer> extends GameEvent<GameType>
|
||||
{
|
||||
private PlayerType _player;
|
||||
|
||||
public GamePlayerJoinedEvent(GameType game, PlayerType player)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public PlayerType GetPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class GamePlayerQuitEvent<GameType extends IGame<?, PlayerType>, PlayerType extends IGamePlayer> extends GameEvent<GameType>
|
||||
{
|
||||
private PlayerType _player;
|
||||
|
||||
public GamePlayerQuitEvent(GameType game, PlayerType player)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public PlayerType GetPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package nautilus.game.core.events;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class GameStartedEvent<GameType extends IGame<?, ? extends IGamePlayer>> extends GameEvent<GameType>
|
||||
{
|
||||
public GameStartedEvent(GameType game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package nautilus.game.core.events.team;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
import nautilus.game.core.events.GameFinishedEvent;
|
||||
import nautilus.game.core.game.ITeamGame;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
public class TeamGameFinishedEvent<GameType extends ITeamGame<? extends ITeamArena, PlayerType, PlayerTeamType>, PlayerTeamType extends ITeam<PlayerType>, PlayerType extends ITeamGamePlayer<PlayerTeamType>> extends GameFinishedEvent<GameType>
|
||||
{
|
||||
private PlayerTeamType _winner;
|
||||
|
||||
public TeamGameFinishedEvent(GameType game, PlayerTeamType winner)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_winner = winner;
|
||||
}
|
||||
|
||||
public PlayerTeamType GetWinningTeam()
|
||||
{
|
||||
return _winner;
|
||||
}
|
||||
}
|
@ -1,453 +0,0 @@
|
||||
package nautilus.game.core.game;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Skill.ISkill;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import nautilus.game.core.arena.IArena;
|
||||
import nautilus.game.core.notifier.PlayerNotifier;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
import nautilus.minecraft.core.utils.GenericRunnable;
|
||||
|
||||
public abstract class Game<PlayerType extends IGamePlayer, ArenaType extends IArena> implements IGame<ArenaType, PlayerType>, Listener, Runnable
|
||||
{
|
||||
protected JavaPlugin Plugin;
|
||||
protected ClassManager ClassManager;
|
||||
protected ConditionManager ConditionManager;
|
||||
protected Energy Energy;
|
||||
protected ArenaType Arena;
|
||||
protected Map<String, PlayerType> Players;
|
||||
protected Map<String, PlayerType> Spectators;
|
||||
protected int PlayerLives = 1;
|
||||
protected int ScoreLimit;
|
||||
protected long StartTime;
|
||||
protected boolean HasStarted;
|
||||
protected boolean CountdownRunning;
|
||||
|
||||
protected HashMap<String, Integer> PlayerTaskIdMap;
|
||||
|
||||
protected int UpdaterTaskId;
|
||||
protected PlayerNotifier<IGame<ArenaType, PlayerType>, ArenaType, PlayerType> Notifier;
|
||||
|
||||
private int _countDown;
|
||||
|
||||
public Game(JavaPlugin plugin, ClassManager classManager, ConditionManager conditionManager, Energy energy)
|
||||
{
|
||||
Plugin = plugin;
|
||||
ClassManager = classManager;
|
||||
ConditionManager = conditionManager;
|
||||
Energy = energy;
|
||||
Players = new HashMap<String, PlayerType>();
|
||||
Spectators = new HashMap<String, PlayerType>();
|
||||
|
||||
PlayerTaskIdMap = new HashMap<String, Integer>();
|
||||
|
||||
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
Update();
|
||||
}
|
||||
|
||||
protected void Update() { }
|
||||
|
||||
protected abstract PlayerType CreateGamePlayer(Player player, int playerLives);
|
||||
|
||||
@Override
|
||||
public void RemovePlayer(PlayerType player)
|
||||
{
|
||||
if (Players.containsKey(player.getName()))
|
||||
{
|
||||
Players.remove(player.getName());
|
||||
ClearPlayerSettings(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void RemoveSpectator(PlayerType player)
|
||||
{
|
||||
if (Spectators.containsKey(player.getName()))
|
||||
{
|
||||
Spectators.remove(player.getName());
|
||||
ClearSpectatorSettings(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsPlayerInGame(Player player)
|
||||
{
|
||||
return Players.containsKey(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsSpectatorInGame(Player player)
|
||||
{
|
||||
return Spectators.containsKey(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerType AddPlayerToGame(Player player)
|
||||
{
|
||||
PlayerType gamePlayer = CreateGamePlayer(player, PlayerLives);
|
||||
Players.put(gamePlayer.getName(), gamePlayer);
|
||||
gamePlayer.SetClass(ClassManager.Get(player));
|
||||
|
||||
return gamePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerType AddSpectatorToGame(Player player, Location to)
|
||||
{
|
||||
PlayerType gamePlayer = CreateGamePlayer(player, PlayerLives);
|
||||
Spectators.put(gamePlayer.getName(), gamePlayer);
|
||||
|
||||
gamePlayer.SetSpectating(true);
|
||||
gamePlayer.teleport(to);
|
||||
gamePlayer.getInventory().addItem(new ItemStack(Material.SHEARS, 1));
|
||||
|
||||
ConditionManager.Factory().Cloak("Spectator", player, player, 7200, false, true);
|
||||
|
||||
return gamePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerType GetPlayer(Player player)
|
||||
{
|
||||
return Players.get(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerType GetPlayer(String playerName)
|
||||
{
|
||||
return Players.get(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerType GetSpectator(Player player)
|
||||
{
|
||||
return Spectators.get(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PlayerType> GetPlayers()
|
||||
{
|
||||
return Players.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PlayerType> GetSpectators()
|
||||
{
|
||||
return Spectators.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateReconnectedPlayer(Player player)
|
||||
{
|
||||
Entry<String, PlayerType> oldPlayerEntry = GetGamePlayer(player.getName());
|
||||
|
||||
if (oldPlayerEntry != null)
|
||||
{
|
||||
PlayerType oldPlayer = oldPlayerEntry.getValue();
|
||||
PlayerType newPlayer = CreateGamePlayer(player, oldPlayer.GetRemainingLives());
|
||||
|
||||
UpdateNewPlayerWithOldPlayer(newPlayer, oldPlayer);
|
||||
|
||||
ClientClass client = ClassManager.Get(player);
|
||||
|
||||
if (oldPlayer.GetClass().GetDefaultItems() != null)
|
||||
{
|
||||
for (Entry<Integer, ItemStack> item : oldPlayer.GetClass().GetDefaultItems().entrySet())
|
||||
{
|
||||
client.PutDefaultItem(item.getValue(), item.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
if (oldPlayer.GetClass().GetDefaultArmor() != null)
|
||||
{
|
||||
client.SetDefaultHead(oldPlayer.GetClass().GetDefaultArmor()[3]);
|
||||
client.SetDefaultChest(oldPlayer.GetClass().GetDefaultArmor()[2]);
|
||||
client.SetDefaultLegs(oldPlayer.GetClass().GetDefaultArmor()[1]);
|
||||
client.SetDefaultFeet(oldPlayer.GetClass().GetDefaultArmor()[0]);
|
||||
}
|
||||
|
||||
client.SetGameClass(oldPlayer.GetClass().GetGameClass());
|
||||
|
||||
if (oldPlayer.GetClass().GetDefaultSkills() != null)
|
||||
{
|
||||
client.ClearDefaultSkills();
|
||||
|
||||
for (ISkill skill : oldPlayer.GetClass().GetDefaultSkills())
|
||||
{
|
||||
client.AddSkill(skill);
|
||||
}
|
||||
}
|
||||
|
||||
Players.put(player.getName(), newPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerType> GetAssailants(Player player)
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasStarted()
|
||||
{
|
||||
return HasStarted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsInArena(Location location)
|
||||
{
|
||||
return Arena.IsInArena(location.toVector());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanMove(PlayerType player, Location from, Location to)
|
||||
{
|
||||
return !CountdownRunning || Arena.CanMove(player.getName(), from != null ? from.toVector() : null, to != null ? to.toVector() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanInteract(PlayerType player, Block block)
|
||||
{
|
||||
return !CountdownRunning || Arena.CanInteract(player.getName(), block);
|
||||
}
|
||||
|
||||
public void StartRespawnFor(PlayerType player)
|
||||
{
|
||||
ResetPlayer(player);
|
||||
|
||||
player.SetSpectating(true);
|
||||
player.SetDead(true);
|
||||
|
||||
ConditionManager.Factory().Cloak("Death", player.GetPlayer(), player.GetPlayer(), 10, false, true);
|
||||
|
||||
PlayerTaskIdMap.put(player.getName(), Plugin.getServer().getScheduler().scheduleSyncDelayedTask(Plugin, new GenericRunnable<String>(player.getName())
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
PlayerType player = GetPlayer(t);
|
||||
|
||||
if (player != null && player.isOnline() && HasStarted)
|
||||
{
|
||||
ResetPlayer(player);
|
||||
RespawnPlayer(player);
|
||||
|
||||
player.SetSpectating(false);
|
||||
player.SetDead(false);
|
||||
}
|
||||
|
||||
ConditionManager.EndCondition(player.GetPlayer(), ConditionType.CLOAK, null);
|
||||
ConditionManager.Factory().Regen("Respawn", player.GetPlayer(), player.GetPlayer(), 7, 3, true, true, true);
|
||||
|
||||
PlayerTaskIdMap.remove(player.getName());
|
||||
}
|
||||
}, 200L));
|
||||
}
|
||||
|
||||
public void ResetPlayer(PlayerType player)
|
||||
{
|
||||
player.setFireTicks(0);
|
||||
player.setHealth(20);
|
||||
player.setVelocity(new Vector(0,0,0));
|
||||
player.setFoodLevel(20);
|
||||
player.GetPlayer().setFallDistance(0);
|
||||
player.RemoveArrows();
|
||||
player.GetPlayer().eject();
|
||||
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(new ItemStack[4]);
|
||||
|
||||
for (PotionEffect potionEffect : player.GetPlayer().getActivePotionEffects())
|
||||
{
|
||||
player.GetPlayer().addPotionEffect(new PotionEffect(potionEffect.getType(), 0, 0), true);
|
||||
}
|
||||
|
||||
if (player.GetPlayer().isOnline())
|
||||
{
|
||||
Energy.Get(player.GetPlayer()).Energy = Energy.GetMax(player.GetPlayer());
|
||||
ClassManager.Get(player.GetPlayer()).ResetSkills(player.GetPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public void Activate(ArenaType arena)
|
||||
{
|
||||
Arena = arena;
|
||||
Notifier = new PlayerNotifier<IGame<ArenaType, PlayerType>, ArenaType, PlayerType>(Plugin, "Dominate");
|
||||
|
||||
_countDown = 30;
|
||||
CountdownRunning = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateStartTimer(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
if (!CountdownRunning)
|
||||
return;
|
||||
|
||||
if (_countDown == 0)
|
||||
{
|
||||
ReallyStartGame();
|
||||
CountdownRunning = false;
|
||||
}
|
||||
else if (_countDown == 1)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers("Game starting in 1 second.", GetPlayers());
|
||||
}
|
||||
else if (_countDown < 11)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers("Game starting in " + _countDown + " seconds.", GetPlayers());
|
||||
}
|
||||
else if (_countDown == 15)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers("Game starting in " + _countDown + " seconds.", GetPlayers());
|
||||
}
|
||||
else if (_countDown == 30)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers("Game starting in " + _countDown + " seconds.", GetPlayers());
|
||||
}
|
||||
else if (_countDown == 45)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers("Game starting in " + _countDown + " seconds.", GetPlayers());
|
||||
}
|
||||
|
||||
_countDown--;
|
||||
}
|
||||
|
||||
public boolean IsActive()
|
||||
{
|
||||
return CountdownRunning || HasStarted;
|
||||
}
|
||||
|
||||
protected void ReallyStartGame()
|
||||
{
|
||||
StartTime = System.currentTimeMillis();
|
||||
HasStarted = true;
|
||||
|
||||
for (Entity entity : Arena.GetWorld().getEntitiesByClasses(Item.class, Arrow.class))
|
||||
{
|
||||
if (Arena.IsInArena(entity.getLocation().toVector()))
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
|
||||
UpdaterTaskId = Plugin.getServer().getScheduler().scheduleSyncRepeatingTask(Plugin, this, 0L, 10L);
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
for (PlayerType player : Players.values())
|
||||
{
|
||||
ClearPlayerSettings(player);
|
||||
}
|
||||
|
||||
for (PlayerType spectator : Spectators.values())
|
||||
{
|
||||
ClearSpectatorSettings(spectator);
|
||||
}
|
||||
|
||||
Players.clear();
|
||||
Spectators.clear();
|
||||
|
||||
Plugin.getServer().getScheduler().cancelTask(UpdaterTaskId);
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
Arena = null;
|
||||
Plugin = null;
|
||||
Players = null;
|
||||
Spectators = null;
|
||||
HasStarted = false;
|
||||
}
|
||||
|
||||
protected void ClearSpectatorSettings(PlayerType spectator)
|
||||
{
|
||||
ConditionManager.EndCondition(spectator.GetPlayer(), ConditionType.CLOAK, null);
|
||||
spectator.SetSpectating(false);
|
||||
}
|
||||
|
||||
protected void ClearPlayerSettings(PlayerType player) { }
|
||||
|
||||
protected Entry<String, PlayerType> GetGamePlayer(String playerName)
|
||||
{
|
||||
for (Entry<String, PlayerType> player : Players.entrySet())
|
||||
{
|
||||
if (player.getKey().equalsIgnoreCase(playerName))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArenaType GetArena()
|
||||
{
|
||||
return Arena;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long GetStartTime()
|
||||
{
|
||||
return StartTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetWinLimit()
|
||||
{
|
||||
return ScoreLimit;
|
||||
}
|
||||
|
||||
protected void UpdateNewPlayerWithOldPlayer(PlayerType newPlayer, PlayerType oldPlayer)
|
||||
{
|
||||
newPlayer.SetLives(oldPlayer.GetRemainingLives());
|
||||
newPlayer.AddKills(oldPlayer.GetKills());
|
||||
newPlayer.AddAssists(oldPlayer.GetAssists());
|
||||
newPlayer.AddDeaths(oldPlayer.GetDeaths());
|
||||
newPlayer.AddPoints(oldPlayer.GetPoints());
|
||||
newPlayer.SetLogoutTime(oldPlayer.GetLogoutTime());
|
||||
newPlayer.SetDead(oldPlayer.IsDead());
|
||||
newPlayer.SetSpectating(oldPlayer.IsSpectating());
|
||||
newPlayer.SetClass(oldPlayer.GetClass());
|
||||
Location lastInArenaPosition = oldPlayer.GetLastInArenaPosition();
|
||||
|
||||
if (lastInArenaPosition != null)
|
||||
{
|
||||
newPlayer.SetLastInArenaPosition(lastInArenaPosition.getWorld(), lastInArenaPosition.getX(), lastInArenaPosition.getY(), lastInArenaPosition.getZ());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package nautilus.game.core.game;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface IGame<ArenaType extends IArena, PlayerType extends IGamePlayer>
|
||||
{
|
||||
boolean IsPlayerInGame(Player player);
|
||||
PlayerType GetPlayer(Player player);
|
||||
PlayerType GetPlayer(String playerName);
|
||||
PlayerType GetSpectator(Player player);
|
||||
Collection<PlayerType> GetPlayers();
|
||||
|
||||
void RemovePlayer(PlayerType player);
|
||||
void RemoveSpectator(PlayerType player);
|
||||
void UpdateReconnectedPlayer(Player player);
|
||||
|
||||
List<PlayerType> GetAssailants(Player player);
|
||||
|
||||
boolean HasStarted();
|
||||
boolean CanMove(PlayerType player, Location from, Location to);
|
||||
boolean CanInteract(PlayerType player, Block block);
|
||||
PlayerType AddPlayerToGame(Player player);
|
||||
PlayerType AddSpectatorToGame(Player player, Location to);
|
||||
boolean IsInArena(Location location);
|
||||
ArenaType GetArena();
|
||||
|
||||
void Activate(ArenaType arena);
|
||||
boolean IsActive();
|
||||
void Deactivate();
|
||||
|
||||
void StartRespawnFor(PlayerType player);
|
||||
void RespawnPlayer(PlayerType player);
|
||||
void ResetPlayer(PlayerType player);
|
||||
|
||||
long GetStartTime();
|
||||
int GetWinLimit();
|
||||
boolean IsSpectatorInGame(Player player);
|
||||
Collection<PlayerType> GetSpectators();
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package nautilus.game.core.game;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
public interface ITeamGame<ArenaType extends ITeamArena, PlayerType extends ITeamGamePlayer<PlayerTeamType>, PlayerTeamType extends ITeam<PlayerType>> extends IGame<ArenaType, PlayerType>
|
||||
{
|
||||
PlayerTeamType GetBlueTeam();
|
||||
PlayerTeamType GetRedTeam();
|
||||
|
||||
void ActivatePlayer(PlayerType player);
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package nautilus.game.core.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import nautilus.game.core.arena.Region;
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
import nautilus.game.core.engine.TeamType;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
public abstract class Team<PlayerType extends ITeamGamePlayer<PlayerTeamType>, PlayerTeamType extends ITeam<PlayerType>> implements ITeam<PlayerType>
|
||||
{
|
||||
private int _score;
|
||||
private TeamType _teamType;
|
||||
private Region _spawnRoom;
|
||||
|
||||
protected List<PlayerType> Players;
|
||||
|
||||
public Team(TeamType teamType)
|
||||
{
|
||||
_teamType = teamType;
|
||||
Players = new ArrayList<PlayerType>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeamType GetTeamType()
|
||||
{
|
||||
return _teamType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerType> GetPlayers()
|
||||
{
|
||||
return Players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void RemovePlayer(PlayerType player)
|
||||
{
|
||||
player.SetTeam(null);
|
||||
Players.remove(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddPoint()
|
||||
{
|
||||
_score++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddPoints(int points)
|
||||
{
|
||||
_score += points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetScore(int score)
|
||||
{
|
||||
_score = score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetScore()
|
||||
{
|
||||
return _score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClearPlayers()
|
||||
{
|
||||
Players.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetSpawnRoom(Region spawnRoom)
|
||||
{
|
||||
_spawnRoom = spawnRoom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsInSpawnRoom(Location location)
|
||||
{
|
||||
return _spawnRoom.Contains(location.toVector());
|
||||
}
|
||||
}
|
@ -1,235 +0,0 @@
|
||||
package nautilus.game.core.game;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
import nautilus.game.core.engine.TeamType;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class TeamGame<PlayerType extends ITeamGamePlayer<PlayerTeamType>, PlayerTeamType extends ITeam<PlayerType>, ArenaType extends ITeamArena> extends Game<PlayerType, ArenaType> implements ITeamGame<ArenaType, PlayerType, PlayerTeamType>
|
||||
{
|
||||
private Random _random;
|
||||
|
||||
protected PlayerTeamType RedTeam;
|
||||
protected PlayerTeamType BlueTeam;
|
||||
|
||||
public TeamGame(JavaPlugin plugin, ClassManager classManager, mineplex.minecraft.game.core.condition.ConditionManager conditionManager, Energy energy)
|
||||
{
|
||||
super(plugin, classManager, conditionManager, energy);
|
||||
|
||||
_random = new Random();
|
||||
|
||||
RedTeam = CreateTeam(TeamType.RED);
|
||||
BlueTeam = CreateTeam(TeamType.BLUE);
|
||||
}
|
||||
|
||||
protected abstract PlayerTeamType CreateTeam(TeamType teamType);
|
||||
|
||||
@Override
|
||||
public void Activate(ArenaType arena)
|
||||
{
|
||||
super.Activate(arena);
|
||||
|
||||
RedTeam.SetSpawnRoom(arena.GetRedSpawnRoom());
|
||||
BlueTeam.SetSpawnRoom(arena.GetBlueSpawnRoom());
|
||||
|
||||
for (PlayerType player : Players.values())
|
||||
{
|
||||
ActivatePlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void ActivatePlayer(PlayerType player)
|
||||
{
|
||||
if (player.GetTeam() == BlueTeam)
|
||||
{
|
||||
Location spawnPoint = GetRandomSpawnPoint(Arena.GetBlueSpawnPoints());
|
||||
player.SetLastInArenaPosition(spawnPoint.getWorld(), spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ());
|
||||
player.teleport(spawnPoint);
|
||||
}
|
||||
else if (player.GetTeam() == RedTeam)
|
||||
{
|
||||
Location spawnPoint = GetRandomSpawnPoint(Arena.GetRedSpawnPoints());
|
||||
player.SetLastInArenaPosition(spawnPoint.getWorld(), spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ());
|
||||
player.teleport(spawnPoint);
|
||||
}
|
||||
|
||||
if (HasStarted)
|
||||
{
|
||||
ResetPlayer(player);
|
||||
RespawnPlayer(player);
|
||||
|
||||
player.SetSpectating(false);
|
||||
player.SetDead(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetSpectating(true);
|
||||
player.SetDead(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClearPlayerSettings(PlayerType player)
|
||||
{
|
||||
super.ClearPlayerSettings(player);
|
||||
|
||||
player.GetTeam().RemovePlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ReallyStartGame()
|
||||
{
|
||||
super.ReallyStartGame();
|
||||
|
||||
for (PlayerType player : Players.values())
|
||||
{
|
||||
player.StartTimePlay();
|
||||
|
||||
ResetPlayer(player);
|
||||
RespawnPlayer(player);
|
||||
|
||||
player.SetSpectating(false);
|
||||
player.SetDead(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanInteract(PlayerType player, Block block)
|
||||
{
|
||||
if (super.CanInteract(player, block))
|
||||
return true;
|
||||
else if (player.GetTeam().IsInSpawnRoom(block.getLocation()) && player.GetTeam().IsInSpawnRoom(player.getLocation()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Deactivate()
|
||||
{
|
||||
RedTeam.ClearPlayers();
|
||||
BlueTeam.ClearPlayers();
|
||||
|
||||
RedTeam = null;
|
||||
BlueTeam = null;
|
||||
_random = null;
|
||||
|
||||
super.Deactivate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerTeamType GetBlueTeam()
|
||||
{
|
||||
return BlueTeam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerTeamType GetRedTeam()
|
||||
{
|
||||
return RedTeam;
|
||||
}
|
||||
|
||||
protected Location GetRandomSpawnPoint(List<Location> spawnPoints)
|
||||
{
|
||||
Location randomSpawnPoint = spawnPoints.get(_random.nextInt(spawnPoints.size()));
|
||||
return randomSpawnPoint;
|
||||
}
|
||||
|
||||
protected void SpawnPlayer(PlayerType player)
|
||||
{
|
||||
player.GetPlayer().eject();
|
||||
player.GetPlayer().leaveVehicle();
|
||||
|
||||
if (player.GetTeam() == RedTeam)
|
||||
{
|
||||
player.teleport(GetRandomSpawnPoint(Arena.GetRedSpawnPoints()));
|
||||
}
|
||||
else if (player.GetTeam() == GetBlueTeam())
|
||||
{
|
||||
player.teleport(GetRandomSpawnPoint(Arena.GetBlueSpawnPoints()));
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, .5F, 0F);
|
||||
}
|
||||
|
||||
public void RespawnPlayer(PlayerType player)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
SpawnPlayer(player);
|
||||
|
||||
ClassManager.Get(player.getName()).ResetToDefaults(true, true);
|
||||
}
|
||||
|
||||
protected void StopGame()
|
||||
{
|
||||
for (PlayerType player : Players.values())
|
||||
{
|
||||
player.StopTimePlay();
|
||||
|
||||
if (!player.isOnline())
|
||||
continue;
|
||||
|
||||
player.GetPlayer().eject();
|
||||
|
||||
if (player.GetPlayer().isInsideVehicle())
|
||||
player.GetPlayer().leaveVehicle();
|
||||
|
||||
if (player.GetTeam() == BlueTeam)
|
||||
{
|
||||
player.teleport(GetRandomSpawnPoint(Arena.GetBlueSpawnPoints()));
|
||||
}
|
||||
else if (player.GetTeam() == RedTeam)
|
||||
{
|
||||
player.teleport(GetRandomSpawnPoint(Arena.GetRedSpawnPoints()));
|
||||
}
|
||||
|
||||
ResetPlayer(player);
|
||||
|
||||
if (player.isOnline())
|
||||
{
|
||||
ClientClass playerClass = ClassManager.Get(player.getName());
|
||||
playerClass.SetGameClass(null);
|
||||
playerClass.ClearDefaults();
|
||||
}
|
||||
|
||||
player.SetDead(true);
|
||||
player.SetSpectating(true);
|
||||
|
||||
if (PlayerTaskIdMap.containsKey(player.getName()))
|
||||
{
|
||||
Plugin.getServer().getScheduler().cancelTask(PlayerTaskIdMap.get(player.getName()));
|
||||
ConditionManager.EndCondition(player.GetPlayer(), ConditionType.CLOAK, null);
|
||||
|
||||
PlayerTaskIdMap.remove(player.getName());
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, .9f);
|
||||
}
|
||||
|
||||
Plugin.getServer().getScheduler().cancelTask(UpdaterTaskId);
|
||||
}
|
||||
|
||||
protected void UpdateNewPlayerWithOldPlayer(PlayerType newPlayer, PlayerType oldPlayer)
|
||||
{
|
||||
super.UpdateNewPlayerWithOldPlayer(newPlayer, oldPlayer);
|
||||
|
||||
PlayerTeamType playerTeam = oldPlayer.GetTeam();
|
||||
|
||||
playerTeam.RemovePlayer(oldPlayer);
|
||||
playerTeam.AddPlayer(newPlayer);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package nautilus.game.core.notifier;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public interface IPlayerNotifier
|
||||
{
|
||||
void BroadcastMessageToPlayers(String message, Collection<? extends IGamePlayer> players);
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package nautilus.game.core.notifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.core.arena.IArena;
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class PlayerNotifier<GameType extends IGame<ArenaType, PlayerType>, ArenaType extends IArena, PlayerType extends IGamePlayer> implements IPlayerNotifier, Listener
|
||||
{
|
||||
protected JavaPlugin Plugin;
|
||||
protected String ChatCategoryName;
|
||||
|
||||
public PlayerNotifier(JavaPlugin plugin, String chatCategoryName)
|
||||
{
|
||||
Plugin = plugin;
|
||||
ChatCategoryName = chatCategoryName;
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, Plugin);
|
||||
}
|
||||
|
||||
public void NotifyPlayerJoinGame(GameType game, PlayerType player)
|
||||
{
|
||||
BroadcastMessageToGamePlayers(game, player.getName() + " joined the game.");
|
||||
}
|
||||
|
||||
public void BroadcastMessageToPlayers(String message, Collection<? extends IGamePlayer> playersToSpam)
|
||||
{
|
||||
for (IGamePlayer player : playersToSpam)
|
||||
{
|
||||
UtilPlayer.message(player.GetPlayer(), F.main(ChatCategoryName, message));
|
||||
}
|
||||
}
|
||||
|
||||
public void BroadcastMessageToPlayer(String message, Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(ChatCategoryName, message));
|
||||
}
|
||||
|
||||
public void BroadcastMessageToGamePlayers(GameType game, String message)
|
||||
{
|
||||
List<PlayerType> playersToSpam = new ArrayList<PlayerType>(game.GetPlayers());
|
||||
playersToSpam.addAll(game.GetSpectators());
|
||||
|
||||
BroadcastMessageToPlayers(message, playersToSpam);
|
||||
}
|
||||
|
||||
public void BroadcastMessageToOtherGamePlayers(GameType game, String message, Collection<PlayerType> players)
|
||||
{
|
||||
List<PlayerType> playersToSpam = new ArrayList<PlayerType>(game.GetPlayers());
|
||||
|
||||
playersToSpam.addAll(game.GetSpectators());
|
||||
|
||||
for (PlayerType gamePlayer : players)
|
||||
{
|
||||
playersToSpam.remove(gamePlayer);
|
||||
}
|
||||
|
||||
BroadcastMessageToPlayers(message, playersToSpam);
|
||||
}
|
||||
|
||||
public void BroadcastMessageToOtherGamePlayers(GameType game, String message, PlayerType player)
|
||||
{
|
||||
List<PlayerType> playersToSpam = new ArrayList<PlayerType>(game.GetPlayers());
|
||||
playersToSpam.remove(player);
|
||||
|
||||
playersToSpam.addAll(game.GetSpectators());
|
||||
|
||||
BroadcastMessageToPlayers(message, playersToSpam);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package nautilus.game.core.notifier;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
import nautilus.game.core.engine.TeamType;
|
||||
import nautilus.game.core.events.team.TeamGameFinishedEvent;
|
||||
import nautilus.game.core.game.ITeamGame;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
public class TeamPlayerNotifier<GameType extends ITeamGame<ArenaType, PlayerType, PlayerTeamType>, ArenaType extends ITeamArena, PlayerTeamType extends ITeam<PlayerType>, PlayerType extends ITeamGamePlayer<PlayerTeamType>> extends PlayerNotifier<GameType, ArenaType, PlayerType>
|
||||
{
|
||||
public TeamPlayerNotifier(JavaPlugin plugin, String chatCategoryName)
|
||||
{
|
||||
super(plugin, chatCategoryName);
|
||||
}
|
||||
|
||||
public void NotifyGameWin(GameType game, PlayerTeamType team)
|
||||
{
|
||||
BroadcastMessageToGamePlayers(game, "Congratulations " + team.GetTeamType() + " team for winning this match!");
|
||||
}
|
||||
|
||||
public void NotifyPlayerJoinTeam(GameType game, PlayerType player)
|
||||
{
|
||||
BroadcastMessageToOtherGamePlayers(game, player.getName() + " joined the " + player.GetTeam().GetTeamType() + " team.", player);
|
||||
UtilPlayer.message(player.GetPlayer(), F.main("Team", "You joined the " + player.GetTeam().GetTeamType() + " team."));
|
||||
}
|
||||
|
||||
public void NotifyPlayerLeaveTeam(GameType game, PlayerType player)
|
||||
{
|
||||
BroadcastMessageToOtherGamePlayers(game, player.getName() + " left the " + player.GetTeam().GetTeamType() + " team.", player);
|
||||
UtilPlayer.message(player.GetPlayer(), F.main("Team", "You left the " + player.GetTeam().GetTeamType() + " team."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTeamGameFinished(TeamGameFinishedEvent<GameType, PlayerTeamType, PlayerType> event)
|
||||
{
|
||||
BroadcastMessageToGamePlayers(event.GetGame(), GetTeamString(event.GetWinningTeam()) + " has won the game!");
|
||||
}
|
||||
|
||||
protected String GetTeamString(PlayerTeamType team)
|
||||
{
|
||||
String colorString = "" + (team.GetTeamType() == TeamType.RED ? ChatColor.RED : ChatColor.BLUE);
|
||||
return ChatColor.WHITE + "[" + colorString + team.GetTeamType() + ChatColor.WHITE + "]" + ChatColor.GRAY;
|
||||
}
|
||||
}
|
@ -1,297 +0,0 @@
|
||||
package nautilus.game.core.player;
|
||||
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GamePlayer implements IGamePlayer
|
||||
{
|
||||
private Player _player;
|
||||
|
||||
private int _lives;
|
||||
private int _kills;
|
||||
private int _assists;
|
||||
private int _deaths;
|
||||
private int _points;
|
||||
private int _skillTokens;
|
||||
private int _itemTokens;
|
||||
private long _logoutTime;
|
||||
private Location _lastInArenaPosition;
|
||||
private boolean _isDead;
|
||||
private boolean _isSpectating;
|
||||
private long _timePlayed;
|
||||
private long _lastTimePlayStart;
|
||||
|
||||
private ClientClass _clientClass;
|
||||
|
||||
public GamePlayer(JavaPlugin plugin, Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetRemainingLives()
|
||||
{
|
||||
return _lives;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetLives(int getRemainingLives)
|
||||
{
|
||||
_lives = getRemainingLives;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetKills()
|
||||
{
|
||||
return _kills;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddKills(int kills)
|
||||
{
|
||||
_kills += kills;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetAssists()
|
||||
{
|
||||
return _assists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddAssists(int assists)
|
||||
{
|
||||
_assists += assists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetDeaths()
|
||||
{
|
||||
return _deaths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddDeaths(int deaths)
|
||||
{
|
||||
_deaths += deaths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetSkillTokens()
|
||||
{
|
||||
return _skillTokens;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetSkillTokens(int tokens)
|
||||
{
|
||||
_skillTokens = tokens;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetItemTokens()
|
||||
{
|
||||
return _itemTokens;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetItemTokens(int tokens)
|
||||
{
|
||||
_itemTokens = tokens;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetPoints()
|
||||
{
|
||||
return _points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddPoints(int points)
|
||||
{
|
||||
_points += points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetLogoutTime(long logoutTime)
|
||||
{
|
||||
_logoutTime = logoutTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long GetLogoutTime()
|
||||
{
|
||||
return _logoutTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsOut()
|
||||
{
|
||||
return _lives <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetLastInArenaPosition(World world, double x, double y, double z)
|
||||
{
|
||||
_lastInArenaPosition = new Location(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location GetLastInArenaPosition()
|
||||
{
|
||||
return _lastInArenaPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsDead()
|
||||
{
|
||||
return _isDead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetDead(boolean dead)
|
||||
{
|
||||
_isDead = dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Player GetPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public void RemoveArrows()
|
||||
{
|
||||
// WHERE DID IT GO?????? ((CraftPlayer)_player).getHandle().r(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsSpectating()
|
||||
{
|
||||
return _isSpectating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetSpectating(boolean spectating)
|
||||
{
|
||||
_isSpectating = spectating;
|
||||
|
||||
// Fix for arrows hitting dead players.
|
||||
((CraftPlayer)_player).getHandle().spectating = spectating;
|
||||
|
||||
if (spectating)
|
||||
{
|
||||
_player.setAllowFlight(true);
|
||||
_player.setFlying(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.setAllowFlight(false);
|
||||
_player.setFlying(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientClass GetClass()
|
||||
{
|
||||
return _clientClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetClass(ClientClass clientClass)
|
||||
{
|
||||
_clientClass = clientClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long GetTimePlayed()
|
||||
{
|
||||
return _timePlayed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void StartTimePlay()
|
||||
{
|
||||
_lastTimePlayStart = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void StopTimePlay()
|
||||
{
|
||||
_timePlayed += System.currentTimeMillis() - _lastTimePlayStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return _player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String string)
|
||||
{
|
||||
_player.sendMessage(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation()
|
||||
{
|
||||
return _player.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location location)
|
||||
{
|
||||
return _player.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline()
|
||||
{
|
||||
return _player.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFireTicks(int i)
|
||||
{
|
||||
_player.setFireTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(double i)
|
||||
{
|
||||
_player.setHealth(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(int i)
|
||||
{
|
||||
_player.setFoodLevel(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocity(Vector vector)
|
||||
{
|
||||
_player.setVelocity(vector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerInventory getInventory()
|
||||
{
|
||||
return _player.getInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Location location, Sound zombieMetal, float f, float g)
|
||||
{
|
||||
_player.playSound(location, zombieMetal, f, g);
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package nautilus.game.core.player;
|
||||
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public interface IGamePlayer
|
||||
{
|
||||
int GetRemainingLives();
|
||||
void SetLives(int getRemainingLives);
|
||||
int GetKills();
|
||||
void AddKills(int kills);
|
||||
int GetAssists();
|
||||
void AddAssists(int assists);
|
||||
int GetDeaths();
|
||||
void AddDeaths(int deaths);
|
||||
|
||||
void SetLogoutTime(long logoutTime);
|
||||
long GetLogoutTime();
|
||||
boolean IsDead();
|
||||
void SetDead(boolean dead);
|
||||
boolean IsSpectating();
|
||||
void SetSpectating(boolean spectating);
|
||||
Player GetPlayer();
|
||||
void RemoveArrows();
|
||||
|
||||
void StartTimePlay();
|
||||
void StopTimePlay();
|
||||
long GetTimePlayed();
|
||||
|
||||
String getName();
|
||||
void sendMessage(String string);
|
||||
Location getLocation();
|
||||
boolean teleport(Location location);
|
||||
boolean isOnline();
|
||||
|
||||
void setFireTicks(int i);
|
||||
void setHealth(double i);
|
||||
void setFoodLevel(int i);
|
||||
boolean IsOut();
|
||||
void setVelocity(Vector vector);
|
||||
void SetLastInArenaPosition(World world, double x, double y, double z);
|
||||
Location GetLastInArenaPosition();
|
||||
PlayerInventory getInventory();
|
||||
void playSound(Location location, Sound zombieMetal, float f, float g);
|
||||
|
||||
int GetPoints();
|
||||
void AddPoints(int points);
|
||||
void SetSkillTokens(int skillTokens);
|
||||
void SetItemTokens(int itemTokens);
|
||||
int GetSkillTokens();
|
||||
int GetItemTokens();
|
||||
|
||||
ClientClass GetClass();
|
||||
void SetClass(ClientClass clientClass);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package nautilus.game.core.player;
|
||||
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
|
||||
public interface ITeamGamePlayer<Team extends ITeam<? extends ITeamGamePlayer<Team>>> extends IGamePlayer
|
||||
{
|
||||
Team GetTeam();
|
||||
void SetTeam(Team team);
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package nautilus.game.core.player;
|
||||
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class TeamGamePlayer<Team extends ITeam<? extends ITeamGamePlayer<Team>>> extends GamePlayer implements ITeamGamePlayer<Team>
|
||||
{
|
||||
protected Team Team;
|
||||
|
||||
public TeamGamePlayer(JavaPlugin plugin, Player player)
|
||||
{
|
||||
super(plugin, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Team GetTeam()
|
||||
{
|
||||
return Team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetTeam(Team team)
|
||||
{
|
||||
Team = team;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.game.core.scoreboard;
|
||||
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public interface IScoreHandler<PlayerType extends IGamePlayer>
|
||||
{
|
||||
void RewardForDeath(PlayerType player);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package nautilus.game.core.scoreboard;
|
||||
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
public interface ITeamScoreHandler<PlayerType extends ITeamGamePlayer<PlayerTeamType>, PlayerTeamType extends ITeam<PlayerType>> extends IScoreHandler<PlayerType>
|
||||
{
|
||||
void RewardForTeamKill(PlayerType killer, PlayerType victim);
|
||||
|
||||
void RewardForKill(PlayerType killer, PlayerType victim, int assists);
|
||||
|
||||
void RewardForAssist(PlayerType assistant, PlayerType victim);
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package nautilus.game.core.scoreboard;
|
||||
|
||||
import net.minecraft.server.v1_7_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R1.Packet201PlayerInfo;
|
||||
|
||||
public class LineTracker
|
||||
{
|
||||
private String _line = null;
|
||||
private String _oldLine = null;
|
||||
private Packet201PlayerInfo _clearOldPacket;
|
||||
private Packet201PlayerInfo _addNewPacket;
|
||||
private Packet201PlayerInfo _clearNewPacket;
|
||||
|
||||
public LineTracker()
|
||||
{
|
||||
_line = null;
|
||||
}
|
||||
|
||||
public void SetLine(String s)
|
||||
{
|
||||
if (s != null && s.length() > 16)
|
||||
s = s.substring(0, 16);
|
||||
|
||||
_oldLine = _line;
|
||||
_line = s;
|
||||
|
||||
if (_oldLine != null)
|
||||
{
|
||||
_clearOldPacket = new Packet201PlayerInfo(_oldLine, false, 0);
|
||||
}
|
||||
|
||||
if (_line != null)
|
||||
{
|
||||
_addNewPacket = new Packet201PlayerInfo(_line, true, 0);
|
||||
_clearNewPacket = new Packet201PlayerInfo(_line, false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void DisplayLineToPlayer(EntityPlayer entityPlayer)
|
||||
{
|
||||
if (_oldLine != null)
|
||||
{
|
||||
entityPlayer.playerConnection.sendPacket(_clearOldPacket);
|
||||
}
|
||||
|
||||
if (_line != null)
|
||||
{
|
||||
entityPlayer.playerConnection.sendPacket(_addNewPacket);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveLineForPlayer(EntityPlayer entityPlayer)
|
||||
{
|
||||
if (_line != null)
|
||||
{
|
||||
entityPlayer.playerConnection.sendPacket(_clearNewPacket);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearOldLine()
|
||||
{
|
||||
_oldLine = null;
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package nautilus.game.core.scoreboard;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class PlayerPointSorter<PlayerType extends IGamePlayer> implements Comparator<PlayerType>
|
||||
{
|
||||
public int compare(PlayerType a, PlayerType b)
|
||||
{
|
||||
if (a.GetPoints() != b.GetPoints())
|
||||
return b.GetPoints() - a.GetPoints();
|
||||
|
||||
return a.getName().toLowerCase().compareTo(b.getName().toLowerCase());
|
||||
}
|
||||
}
|
@ -1,304 +0,0 @@
|
||||
package nautilus.game.core.scoreboard;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.packethandler.IPacketRunnable;
|
||||
import mineplex.core.packethandler.PacketArrayList;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
import nautilus.game.core.game.ITeamGame;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
import nautilus.minecraft.core.utils.TimeStuff;
|
||||
import net.minecraft.server.v1_7_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R1.Packet;
|
||||
import net.minecraft.server.v1_7_R1.Packet201PlayerInfo;
|
||||
|
||||
public class TabScoreboard<GameType extends ITeamGame<?, PlayerType, TeamType>, PlayerType extends ITeamGamePlayer<TeamType>, TeamType extends ITeam<PlayerType>> implements IPacketRunnable
|
||||
{
|
||||
protected CoreClientManager ClientManager;
|
||||
protected ClassManager ClassManager;
|
||||
protected PacketHandler PacketHandler;
|
||||
protected NautHashMap<String, NautHashMap<Integer, LineTracker>> MainColumn;
|
||||
|
||||
protected GameType Game;
|
||||
protected NautHashMap<Integer, LineTracker> RedColumn;
|
||||
protected NautHashMap<Integer, LineTracker> BlueColumn;
|
||||
|
||||
private boolean _updating = false;
|
||||
|
||||
public TabScoreboard(JavaPlugin plugin, CoreClientManager clientManager, ClassManager classManager, PacketHandler packetHandler, GameType game)
|
||||
{
|
||||
ClientManager = clientManager;
|
||||
ClassManager = classManager;
|
||||
PacketHandler = packetHandler;
|
||||
Game = game;
|
||||
RedColumn = new NautHashMap<Integer, LineTracker>();
|
||||
BlueColumn = new NautHashMap<Integer, LineTracker>();
|
||||
MainColumn = new NautHashMap<String, NautHashMap<Integer, LineTracker>>();
|
||||
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
RedColumn.put(i, new LineTracker());
|
||||
}
|
||||
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
BlueColumn.put(i, new LineTracker());
|
||||
}
|
||||
|
||||
PacketHandler.AddPacketRunnable(this);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
SetRedTeamInfo();
|
||||
SetBlueTeamInfo();
|
||||
|
||||
for (PlayerType player : Game.GetPlayers())
|
||||
{
|
||||
UpdateForPlayer(player);
|
||||
|
||||
if (player.isOnline())
|
||||
SendPlayerScoreboard(player);
|
||||
}
|
||||
|
||||
for (PlayerType player : Game.GetSpectators())
|
||||
{
|
||||
UpdateForPlayer(player);
|
||||
SendPlayerScoreboard(player);
|
||||
}
|
||||
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
RedColumn.get(i).ClearOldLine();
|
||||
}
|
||||
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
BlueColumn.get(i).ClearOldLine();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddSpectator(PlayerType spectator)
|
||||
{
|
||||
UpdateForPlayer(spectator);
|
||||
SendPlayerScoreboard(spectator);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
RedColumn.get(i).SetLine("");
|
||||
}
|
||||
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
BlueColumn.get(i).SetLine("");
|
||||
}
|
||||
|
||||
Packet201PlayerInfo clearPacket = new Packet201PlayerInfo("", false, 0);
|
||||
|
||||
_updating = true;
|
||||
for (PlayerType player : Game.GetPlayers())
|
||||
{
|
||||
NautHashMap<Integer, LineTracker> playerLines = MainColumn.get(player.getName());
|
||||
|
||||
// If player quit as game was preparing and never reconnected...
|
||||
if (playerLines != null)
|
||||
{
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
playerLines.get(i).SetLine("");
|
||||
}
|
||||
|
||||
SendPlayerScoreboard(player);
|
||||
|
||||
EntityPlayer entityPlayer = ((CraftPlayer)player.GetPlayer()).getHandle();
|
||||
|
||||
entityPlayer.playerConnection.sendPacket(clearPacket);
|
||||
}
|
||||
}
|
||||
|
||||
for (PlayerType player : Game.GetSpectators())
|
||||
{
|
||||
NautHashMap<Integer, LineTracker> playerLines = MainColumn.get(player.getName());
|
||||
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
playerLines.get(i).SetLine("");
|
||||
}
|
||||
|
||||
SendPlayerScoreboard(player);
|
||||
|
||||
EntityPlayer entityPlayer = ((CraftPlayer)player.GetPlayer()).getHandle();
|
||||
|
||||
entityPlayer.playerConnection.sendPacket(clearPacket);
|
||||
}
|
||||
_updating = false;
|
||||
|
||||
PacketHandler.RemovePacketRunnable(this);
|
||||
}
|
||||
|
||||
public void UpdateForPlayer(PlayerType player)
|
||||
{
|
||||
SetMainInfo(player);
|
||||
}
|
||||
|
||||
protected void SetRedTeamInfo()
|
||||
{
|
||||
RedColumn.get(0).SetLine(ChatColor.RED + " [RED]");
|
||||
RedColumn.get(1).SetLine(ChatColor.RED + "Score: " + ChatColor.WHITE + Game.GetRedTeam().GetScore());
|
||||
RedColumn.get(8).SetLine(ChatColor.RED + " [Players]");
|
||||
RedColumn.get(9).SetLine(ChatColor.RED + " [K/D/A S]");
|
||||
|
||||
String spacer = "";
|
||||
for (int i=0; i < 5; i++)
|
||||
{
|
||||
int lineIndex = 10 + i * 2;
|
||||
spacer += " ";
|
||||
|
||||
if (i < Game.GetRedTeam().GetPlayers().size())
|
||||
{
|
||||
PlayerType player = Game.GetRedTeam().GetPlayers().get(i);
|
||||
|
||||
ChatColor playerColor = !player.isOnline() ? ChatColor.DARK_GRAY : ChatColor.WHITE;
|
||||
RedColumn.get(lineIndex).SetLine(playerColor + player.getName());
|
||||
RedColumn.get(lineIndex+1).SetLine(ChatColor.RED + "" + player.GetKills() + "/" + player.GetDeaths() + "/" + player.GetAssists() + " " + player.GetPoints() + spacer);
|
||||
}
|
||||
else
|
||||
{
|
||||
RedColumn.get(lineIndex).SetLine(ChatColor.RED + "" + ChatColor.GREEN + spacer);
|
||||
RedColumn.get(lineIndex+1).SetLine(ChatColor.RED + "" + ChatColor.BLUE + spacer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetMainInfo(PlayerType player)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
ClientClass clientPlayer = ClassManager.Get(player.GetPlayer());
|
||||
|
||||
if (!MainColumn.containsKey(player.getName()))
|
||||
{
|
||||
NautHashMap<Integer, LineTracker> playerLines = new NautHashMap<Integer, LineTracker>();
|
||||
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
playerLines.put(i, new LineTracker());
|
||||
}
|
||||
|
||||
MainColumn.put(player.getName(), playerLines);
|
||||
}
|
||||
|
||||
NautHashMap<Integer, LineTracker> playerLines = MainColumn.get(player.getName());
|
||||
|
||||
playerLines.get(0).SetLine(ChatColor.GREEN + " [Dominate]");
|
||||
playerLines.get(1).SetLine(ChatColor.GREEN + "Map:");
|
||||
playerLines.get(2).SetLine(Game.GetArena().GetName());
|
||||
playerLines.get(3).SetLine(ChatColor.GREEN + "Win Limit:");
|
||||
playerLines.get(4).SetLine(Game.GetWinLimit() + "");
|
||||
playerLines.get(5).SetLine(ChatColor.GREEN + "Duration:");
|
||||
playerLines.get(6).SetLine((Game.GetStartTime() == 0 ? "0" : TimeStuff.GetTimespanString(System.currentTimeMillis() - Game.GetStartTime())));
|
||||
playerLines.get(7).SetLine(ChatColor.GREEN + "");
|
||||
playerLines.get(8).SetLine(ChatColor.GREEN + " [Stats]");
|
||||
playerLines.get(9).SetLine(ChatColor.GREEN + "Class:" );
|
||||
playerLines.get(10).SetLine((clientPlayer.GetGameClass() == null ? "None" : clientPlayer.GetGameClass().GetName()));
|
||||
playerLines.get(11).SetLine(ChatColor.GREEN + "Kills:");
|
||||
playerLines.get(12).SetLine(player.GetKills() + " ");
|
||||
playerLines.get(13).SetLine(ChatColor.GREEN + "Deaths:");
|
||||
playerLines.get(14).SetLine(player.GetDeaths() + " ");
|
||||
playerLines.get(15).SetLine(ChatColor.GREEN + "Assists:");
|
||||
playerLines.get(16).SetLine(player.GetAssists() + " ");
|
||||
playerLines.get(17).SetLine(ChatColor.GREEN + "Score:");
|
||||
playerLines.get(18).SetLine(player.GetPoints() + " ");
|
||||
playerLines.get(19).SetLine(ChatColor.GREEN + " ");
|
||||
}
|
||||
|
||||
protected void SetBlueTeamInfo()
|
||||
{
|
||||
BlueColumn.get(0).SetLine(ChatColor.BLUE + " [BLUE]");
|
||||
BlueColumn.get(1).SetLine(ChatColor.BLUE + "Score: " + ChatColor.WHITE + Game.GetBlueTeam().GetScore());
|
||||
BlueColumn.get(8).SetLine(ChatColor.BLUE + " [Players]");
|
||||
BlueColumn.get(9).SetLine(ChatColor.BLUE + " [K/D/A S]");
|
||||
|
||||
String spacer = "";
|
||||
for (int i=0; i < 5; i++)
|
||||
{
|
||||
int lineIndex = 10 + i * 2;
|
||||
spacer += " ";
|
||||
|
||||
if (i < Game.GetBlueTeam().GetPlayers().size())
|
||||
{
|
||||
PlayerType player = Game.GetBlueTeam().GetPlayers().get(i);
|
||||
|
||||
ChatColor playerColor = !player.isOnline() ? ChatColor.DARK_GRAY : ChatColor.WHITE;
|
||||
BlueColumn.get(lineIndex).SetLine(playerColor + player.getName());
|
||||
BlueColumn.get(lineIndex+1).SetLine(ChatColor.BLUE + "" + player.GetKills() + "/" + player.GetDeaths() + "/" + player.GetAssists() + " " + player.GetPoints() + spacer);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlueColumn.get(lineIndex).SetLine(ChatColor.BLUE + " " + ChatColor.GREEN + spacer);
|
||||
BlueColumn.get(lineIndex+1).SetLine(ChatColor.BLUE + " " + ChatColor.RED + spacer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearScoreboardForSpectator(PlayerType player)
|
||||
{
|
||||
EntityPlayer entityPlayer = ((CraftPlayer)player.GetPlayer()).getHandle();
|
||||
NautHashMap<Integer, LineTracker> playersLines = MainColumn.get(player.getName());
|
||||
|
||||
if (playersLines == null)
|
||||
return;
|
||||
|
||||
_updating = true;
|
||||
for (Integer i=0; i < 20; i++)
|
||||
{
|
||||
RedColumn.get(i).RemoveLineForPlayer(entityPlayer);
|
||||
playersLines.get(i).RemoveLineForPlayer(entityPlayer);
|
||||
BlueColumn.get(i).RemoveLineForPlayer(entityPlayer);
|
||||
}
|
||||
_updating = false;
|
||||
|
||||
MainColumn.remove(player.getName());
|
||||
}
|
||||
|
||||
public void SendPlayerScoreboard(PlayerType player)
|
||||
{
|
||||
EntityPlayer entityPlayer = ((CraftPlayer)player.GetPlayer()).getHandle();
|
||||
NautHashMap<Integer, LineTracker> playersLines = MainColumn.get(player.getName());
|
||||
|
||||
_updating = true;
|
||||
for (int i=0; i < 20; i++)
|
||||
{
|
||||
RedColumn.get(i).DisplayLineToPlayer(entityPlayer);
|
||||
playersLines.get(i).DisplayLineToPlayer(entityPlayer);
|
||||
BlueColumn.get(i).DisplayLineToPlayer(entityPlayer);
|
||||
|
||||
playersLines.get(i).ClearOldLine();
|
||||
}
|
||||
_updating = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(Packet packet, Player owner, PacketArrayList packetList)
|
||||
{
|
||||
if (packet instanceof Packet201PlayerInfo)
|
||||
{
|
||||
if (Game.IsPlayerInGame(owner) && Game.IsActive())
|
||||
return _updating;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package nautilus.game.core.scoreboard;
|
||||
|
||||
import nautilus.game.core.arena.ITeamArena;
|
||||
import nautilus.game.core.engine.ITeam;
|
||||
import nautilus.game.core.game.ITeamGame;
|
||||
import nautilus.game.core.notifier.TeamPlayerNotifier;
|
||||
import nautilus.game.core.player.ITeamGamePlayer;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class TeamGameScoreHandler<NotifierType extends TeamPlayerNotifier<GameType, ArenaType, PlayerTeamType, PlayerType>, GameType extends ITeamGame<ArenaType, PlayerType, PlayerTeamType>, ArenaType extends ITeamArena, PlayerTeamType extends ITeam<PlayerType>, PlayerType extends ITeamGamePlayer<PlayerTeamType>> implements ITeamScoreHandler<PlayerType, PlayerTeamType>, Listener
|
||||
{
|
||||
protected NotifierType Notifier;
|
||||
|
||||
public TeamGameScoreHandler(JavaPlugin plugin, NotifierType notifier)
|
||||
{
|
||||
Notifier = notifier;
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
public void RewardForDeath(PlayerType player)
|
||||
{
|
||||
player.AddPoints(-5);
|
||||
Notifier.BroadcastMessageToPlayer("Your score was reduced by " + ChatColor.YELLOW + 5 + ChatColor.GRAY + " for dying!", player.GetPlayer());
|
||||
}
|
||||
|
||||
public void RewardForTeamKill(PlayerType killer, PlayerType victim)
|
||||
{
|
||||
killer.AddPoints(-25);
|
||||
|
||||
Notifier.BroadcastMessageToPlayer("You team killed " + victim.getName() + " and reduced your score by " + ChatColor.YELLOW + -25 + ChatColor.GRAY + "!", killer.GetPlayer());
|
||||
}
|
||||
|
||||
public void RewardForKill(PlayerType killer, PlayerType victim, int assists)
|
||||
{
|
||||
int deathValue = 15;
|
||||
int deathPoints = deathValue + GetKillModifierValue(killer, victim, assists);
|
||||
|
||||
killer.AddPoints(deathPoints - (assists * 2));
|
||||
|
||||
Notifier.BroadcastMessageToPlayer("You killed " + victim.getName() + " for an additional +" + ChatColor.YELLOW + (deathPoints - (assists * 2)) + ChatColor.GRAY + " to your score!", killer.GetPlayer());
|
||||
}
|
||||
|
||||
public void RewardForAssist(PlayerType assistant, PlayerType victim)
|
||||
{
|
||||
assistant.AddPoints(2);
|
||||
Notifier.BroadcastMessageToPlayer("You helped kill " + victim.getName() + " for an additional +" + ChatColor.YELLOW + 2 + ChatColor.GRAY + " to your score!", assistant.GetPlayer());
|
||||
}
|
||||
|
||||
protected abstract int GetKillModifierValue(PlayerType killer, PlayerType victim, int assists);
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package nautilus.game.core.util;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Timer;
|
||||
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.notifier.IPlayerNotifier;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class BroadcastMinuteTimer extends BroadcastTimer
|
||||
{
|
||||
private BroadcastSecondTimer countdownTimer;
|
||||
|
||||
public BroadcastMinuteTimer(IPlayerNotifier notifier, IGame<?, ? extends IGamePlayer> game, int maxTime, String message, String endMessage, ActionListener listener)
|
||||
{
|
||||
super(notifier, game, maxTime, message, endMessage, listener);
|
||||
|
||||
Timer = new Timer(60*1000, Listener);
|
||||
Timer.setDelay(60*1000);
|
||||
Timer.setInitialDelay(0);
|
||||
|
||||
countdownTimer = new BroadcastSecondTimer(notifier, game, 60, message, EndMessage, new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
KickOffListener();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void LoadListener()
|
||||
{
|
||||
Listener = new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
if (Ticks % 5 == 0)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers(Message + " in " + Ticks + " minutes.", Game.GetPlayers());
|
||||
}
|
||||
else if (Ticks == 3)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers(Message + " in 3 minutes.", Game.GetPlayers());
|
||||
}
|
||||
else if (Ticks == 1)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers(Message + " in 1 minute.", Game.GetPlayers());
|
||||
|
||||
Stop();
|
||||
countdownTimer.Start();
|
||||
}
|
||||
|
||||
Ticks--;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetTimeLeft(long time)
|
||||
{
|
||||
if (time > 60000)
|
||||
{
|
||||
Ticks = (int)(time / 60000);
|
||||
|
||||
if (!IsRunning())
|
||||
Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
Ticks = 0;
|
||||
Stop();
|
||||
countdownTimer.SetTimeLeft(time);
|
||||
countdownTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long GetTimeLeft()
|
||||
{
|
||||
long timeLeft = 0;
|
||||
|
||||
if (Ticks > 0)
|
||||
{
|
||||
timeLeft = Ticks * 60 * 1000;
|
||||
}
|
||||
else if (countdownTimer.IsRunning())
|
||||
{
|
||||
timeLeft = countdownTimer.GetTimeLeft();
|
||||
}
|
||||
|
||||
return timeLeft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean IsRunning()
|
||||
{
|
||||
return Timer.isRunning() || countdownTimer.IsRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Deactivate()
|
||||
{
|
||||
super.Deactivate();
|
||||
|
||||
countdownTimer.Deactivate();
|
||||
countdownTimer = null;
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
package nautilus.game.core.util;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Timer;
|
||||
|
||||
import nautilus.game.core.arena.IArena;
|
||||
import nautilus.game.core.game.IGame;
|
||||
import nautilus.game.core.notifier.IPlayerNotifier;
|
||||
import nautilus.game.core.player.IGamePlayer;
|
||||
|
||||
public class BroadcastSecondTimer extends BroadcastTimer
|
||||
{
|
||||
public BroadcastSecondTimer(IPlayerNotifier notifier, IGame<? extends IArena, ? extends IGamePlayer> game, int maxTime, String message, String endMessage, ActionListener actionListener)
|
||||
{
|
||||
super(notifier, game, maxTime, message, endMessage, actionListener);
|
||||
|
||||
Timer = new Timer(1000, Listener);
|
||||
Timer.setDelay(1000);
|
||||
Timer.setInitialDelay(0);
|
||||
Timer.setRepeats(true);
|
||||
}
|
||||
|
||||
public void LoadListener()
|
||||
{
|
||||
Listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
if (Ticks <= 0)
|
||||
{
|
||||
if (EndMessage != null)
|
||||
Notifier.BroadcastMessageToPlayers(EndMessage, Game.GetPlayers());
|
||||
|
||||
Stop();
|
||||
KickOffListener();
|
||||
}
|
||||
else if (Ticks == 1)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers(Message + " in 1 second.", Game.GetPlayers());
|
||||
}
|
||||
else if (Ticks < 11)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers(Message + " in " + Ticks + " seconds.", Game.GetPlayers());
|
||||
}
|
||||
else if (Ticks == 15)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers(Message + " in " + Ticks + " seconds.", Game.GetPlayers());
|
||||
}
|
||||
else if (Ticks == 30)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers(Message + " in " + Ticks + " seconds.", Game.GetPlayers());
|
||||
}
|
||||
else if (Ticks == 45)
|
||||
{
|
||||
Notifier.BroadcastMessageToPlayers(Message + " in " + Ticks + " seconds.", Game.GetPlayers());
|
||||
}
|
||||
|
||||
Ticks--;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetTimeLeft(long time)
|
||||
{
|
||||
if (time > 1000)
|
||||
{
|
||||
Ticks = (int)(time / 1000);
|
||||
|
||||
if (!IsRunning())
|
||||
Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
Ticks = 0;
|
||||
}
|
||||
|
||||
if (!IsRunning())
|
||||
Start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long GetTimeLeft()
|
||||
{
|
||||
return Ticks * 1000;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user