commit
bf817a931c
@ -0,0 +1,5 @@
|
||||
package mineplex.core.common.api;
|
||||
|
||||
public class ApiException extends Exception
|
||||
{
|
||||
}
|
@ -8,7 +8,9 @@ package mineplex.core.common.api;
|
||||
public enum ApiHost
|
||||
{
|
||||
AMPLIFIERS("10.33.53.12", 7979),
|
||||
ANTISPAM("10.33.53.12", 8181);
|
||||
ANTISPAM("10.33.53.12", 8181),
|
||||
ENDERCHEST("10.33.53.10", 8010)
|
||||
;
|
||||
|
||||
private String _host;
|
||||
private int _port;
|
||||
|
@ -1,6 +1,11 @@
|
||||
package mineplex.core.common.api;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
@ -13,10 +18,18 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import mineplex.core.common.api.enderchest.HashesNotEqualException;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
@ -28,6 +41,11 @@ public class ApiWebCall
|
||||
private PoolingHttpClientConnectionManager _cm;
|
||||
private CloseableHttpClient _httpClient;
|
||||
|
||||
public ApiWebCall(String url)
|
||||
{
|
||||
this(url, new Gson());
|
||||
}
|
||||
|
||||
public ApiWebCall(String url, Gson gson)
|
||||
{
|
||||
_url = url;
|
||||
@ -89,6 +107,50 @@ public class ApiWebCall
|
||||
return returnData;
|
||||
}
|
||||
|
||||
public File getFile(String resource, String savePath) throws HashesNotEqualException, IOException
|
||||
{
|
||||
HttpGet httpGet = new HttpGet(_url + resource);
|
||||
File file = new File(savePath);
|
||||
|
||||
FileOutputStream fos = null;
|
||||
DigestInputStream dis = null;
|
||||
try (CloseableHttpResponse response = _httpClient.execute(httpGet))
|
||||
{
|
||||
MessageDigest md = DigestUtils.getMd5Digest();
|
||||
HttpEntity entity = response.getEntity();
|
||||
dis = new DigestInputStream(entity.getContent(), md);
|
||||
fos = new FileOutputStream(file);
|
||||
IOUtils.copy(dis, fos);
|
||||
|
||||
String calculatedHash = Hex.encodeHexString(md.digest());
|
||||
Header hashHeader = response.getFirstHeader("Content-MD5");
|
||||
|
||||
if (hashHeader != null && !calculatedHash.equals(hashHeader.getValue()))
|
||||
{
|
||||
file.delete();
|
||||
throw new HashesNotEqualException(hashHeader.getValue(), calculatedHash);
|
||||
}
|
||||
} finally {
|
||||
try
|
||||
{
|
||||
if (fos != null) fos.close();
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (dis != null) dis.close();
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
private <T> T parseResponse(CloseableHttpResponse response, Type type) throws IOException
|
||||
{
|
||||
HttpEntity entity = response.getEntity();
|
||||
|
@ -0,0 +1,46 @@
|
||||
package mineplex.core.common.api.enderchest;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import mineplex.core.common.api.ApiHost;
|
||||
import mineplex.core.common.api.ApiWebCall;
|
||||
import mineplex.core.common.util.ZipUtil;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
|
||||
/**
|
||||
* Load worlds from the `enderchest` microservice
|
||||
*/
|
||||
public class EnderchestWorldLoader
|
||||
{
|
||||
private static final String TIMINGS_PREFIX = "Enderchest LoadMap::";
|
||||
private ApiWebCall _webCall;
|
||||
|
||||
public EnderchestWorldLoader()
|
||||
{
|
||||
String url = "http://" + ApiHost.ENDERCHEST.getHost() + ":" + ApiHost.ENDERCHEST.getPort() + "/";
|
||||
_webCall = new ApiWebCall(url);
|
||||
}
|
||||
|
||||
public void loadMap(String mapType, String folder) throws HashesNotEqualException, IOException
|
||||
{
|
||||
TimingManager.start(TIMINGS_PREFIX + "DownloadMap");
|
||||
String fileName = mapType + "_map.zip";
|
||||
File f = _webCall.getFile("map/" + mapType + "/random", fileName);
|
||||
TimingManager.stop(TIMINGS_PREFIX + "DownloadMap");
|
||||
|
||||
TimingManager.start(TIMINGS_PREFIX + "CreateFolders");
|
||||
new File(folder).mkdir();
|
||||
new File(folder + java.io.File.separator + "region").mkdir();
|
||||
new File(folder + java.io.File.separator + "data").mkdir();
|
||||
TimingManager.stop(TIMINGS_PREFIX + "CreateFolders");
|
||||
|
||||
TimingManager.start(TIMINGS_PREFIX + "UnzipToDirectory");
|
||||
ZipUtil.UnzipToDirectory(f.getAbsolutePath(), folder);
|
||||
TimingManager.stop(TIMINGS_PREFIX + "UnzipToDirectory");
|
||||
|
||||
TimingManager.start(TIMINGS_PREFIX + "DeleteZip");
|
||||
f.delete();
|
||||
TimingManager.stop(TIMINGS_PREFIX + "DeleteZip");
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.common.api.enderchest;
|
||||
|
||||
import mineplex.core.common.api.ApiException;
|
||||
|
||||
public class HashesNotEqualException extends ApiException
|
||||
{
|
||||
private String _hashFromServer;
|
||||
private String _calculatedHash;
|
||||
|
||||
public HashesNotEqualException(String hashFromServer, String calculatedHash)
|
||||
{
|
||||
_hashFromServer = hashFromServer;
|
||||
_calculatedHash = calculatedHash;
|
||||
}
|
||||
|
||||
public String getHashFromServer()
|
||||
{
|
||||
return _hashFromServer;
|
||||
}
|
||||
|
||||
public String getGeneratedHash()
|
||||
{
|
||||
return _calculatedHash;
|
||||
}
|
||||
}
|
@ -62,7 +62,8 @@ public class SkinData
|
||||
public final static SkinData HAUNTED_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzUyNTUzOTE3OTcsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9lZWM5MmU4ODNiOGFjODI0MDU5YTk5NGM5NTNjNTQ0NDQ0Yjk3ZWFkZDdhNWFjNGY3ZTZhOTUxOGQ5YTkxMSJ9fX0=", "GqycEQvWoZeXDLAJ6ricUx3coA4Y6AswL0GV1KebetoTkd9XNtkJJ9eUf6ViwpSgmL0H89sdMjghThHKczUEmjaFeNl2Z9cwGnR1WOK3KpD+v8C7f10l2DNd7z8s1clJfkVay/5KkgNMneu+ZStF8mCt+uyOSfZX4toLRBba6ZDaz4RlmcNt3e6h+dCaB/npbrWxddX7YZWsAMEKxmMKrG/Rm1Gx7ZOchmd4l6+pypA3Vrjoc0LVjqDV/TsePiNxV9LWFB7Rc6YGkIyz2+z5m168iLnn4+qMMXOYndwH7RGcTLEJDPRfNjawuPNcRlYZ6bf30S540MQdC0dJbRLu0uT9CAyi1vjxezdKjGJZSiY5WmtWrhkiRRtCMr9fGxBRNxPDdf5bs7IgWClFgafkGFZKZjLlOV8qtlMrPQSduPtGBCM64veJchSMFS6MfxgE2O/+4EZ246ZN1bdV6KiLRDIzFmy9PBn2o6MNtcdFc/G5XdD7aCTwuGD6sbG2T97Aiai56CN1vYsc6yXUfeZafSm6qviXAx3zTEd1aw1oAZLj3PAt0uZRHggsBEKvwPVKsgHsOVFj5vu0BfHFbdaSdhL3GFotk06Ilr5cLxOrTwqoVNp/hiIJ8pu7T0AEWy1pMYD1+RszsTjJ76l305cQ3UHvinjnbXllsFQIIVE899s=");
|
||||
public final static SkinData WITCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM5OTEyMTE1NDQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS81NDg1ZDZlMTBhNmNmMmY3Mzg2NmZhMGRiNjEzOWQ5NWViZDM0ZGZiMGY0YzAxMmRkM2YzYWYxMWQ5ZjQxYyJ9fX0=", "cojkGLflVWxwnhDXmHMke7crkeA78iUYOWY7H3YvMJFD+VZi9E7vUahLTTx5ELH+PvcaHJerSDmuV+Nasc3K2n6zlXXb0B7RB/ose/kdPxHAIJee7IbZX0iFNDn6irUSOS4wOYF/BwaqG3HmpoSxV52SGMs6kqTer2Rjg3X+XwYFFiDHAR/gwhfXLzrM1iBc171vgu6T+kx65iBHa/YB/V/mj8FSxwM0f5IsLpgAEdxDL9PvEKQWgWeZ1CAqEXlGnjPkd9oGzW0TgDz2MksBbYZ2kmn/S53kK9vCrVB7egZPS4VBtKpq1P7Jeu8rtgjnAKVFQJZ2lMHnVRuvGTd8JKoPHarUPpU2LURUMaCtHzSv9v/4gjkafnDhqxG4TTcr5hxFV+ho72HQchoeaUXzIO+Yo71zrVqkrS0hw6OtgMIBlvaGaEUsFvGiCZePBEiHojO43AKqJcJAVeT2RAzHcAaBAO79ACGjNKw/oj02rOurLha9i+99bKui96Eg7SS/nPchbmu5YQ9nSpkW+JeYXnBzGGzNG4y02VWgz15L718+8161zXobhuK07qlY9i1nipFbEJedqG0cfS+AUzauETFvS9nMtxhtftYPCIxm40GQj6e77asNCAEElGssaUGKO3bjm348+oF9tR/eBOYWJQ8kL46IQLDRoop7UhG4ewY=");
|
||||
public final static SkinData TURKEY = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzU3NzM2MTc5MDQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8xYzdmYjczMTRkNmY1ZTMzNmVjN2ViNTI1ZGM0ODMzOWNhMjI4ZDk3ODU1MDM3ZDZhNDIwOGZjNzYwNDc1NiJ9fX0=", "eZWi1LOD8ke7MCUAfhspBCnyfCoGM8suFLKtbW6b27CURoRBG3eKIfwLYYeMp3ObjoZ8gCB90s28Qyw5XMzwvvowy9W/b5cYC0OzQ8+GR7tDZoWc28tGqGBM8cmDJIFQgZdceBIIr2lXeAvEJfLbyrus46hPjk8YTiQW2DsBq88BhKIy6Igb1rGqJ1goVERF07b6+/yMdLKCaT8OZFzKLXfo5rY5gr6HLnvsQiNL9aTrl74agXn1GUcP+QVNe7/c9lYmv5vLCBst1YiIPq27NZASZ++Fwyv6+PRlaFZZYtMHVd4UZeYPl7ak1Cdi/1sUcRpkBbJM8AHIrqq0iuXxrLbc6ldQ2cYQKHg9ljIpW/EZanuf6Wgm/LK1JnxXne9GUb/xPzB1EnZ95i8/u9WJa+NixEcfc3pAzDPYncIR8lishFwyBRta6BCG76U3UY2lQr3YD/48AJ49r7+WVU0gOP/h2SDSdAZHEdvkpVJ0w/xA+SevJ7Y7xA5EJ655YMQ0F8f3WUFTf1pFklE5E+fwkMVCWOPw7UMy558IcRSpdWAPPyf8sc7CpDqRk37/vXWRDa+7YBfgskK6B2eXowrzThUOBx+AmDTF3Rv8ZSr1Un0FWGi+GQ5ny7W9dJBMomzyMUbzz9stsCml5XB+6xLP2MD+9lO1bHipKS6qkhtZChE=");
|
||||
|
||||
|
||||
|
||||
// Comments this out for now, so it doesn't load the player profile
|
||||
// A better way to do this would check for the properties when getting the skull or the skin
|
||||
// Might change on the next version
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.timing;
|
||||
package mineplex.core.common.timing;
|
||||
|
||||
public class TimeData
|
||||
{
|
@ -1,17 +1,11 @@
|
||||
package mineplex.core.timing;
|
||||
package mineplex.core.common.timing;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
|
||||
public class TimingManager implements Listener
|
||||
public class TimingManager
|
||||
{
|
||||
private static TimingManager _instance;
|
||||
|
||||
private JavaPlugin _plugin;
|
||||
private static NautHashMap<String, Long> _timingList = new NautHashMap<String, Long>();
|
||||
private static NautHashMap<String, TimeData> _totalList = new NautHashMap<String, TimeData>();
|
||||
|
||||
@ -20,30 +14,6 @@ public class TimingManager implements Listener
|
||||
|
||||
public static boolean Debug = true;
|
||||
|
||||
protected TimingManager(JavaPlugin plugin)
|
||||
{
|
||||
_instance = this;
|
||||
|
||||
_plugin = plugin;
|
||||
|
||||
_plugin.getServer().getPluginManager().registerEvents(this, _plugin);
|
||||
}
|
||||
|
||||
public static TimingManager Initialize(JavaPlugin plugin)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new TimingManager(plugin);
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public static TimingManager instance()
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public static void startTotal(String title)
|
||||
{
|
||||
if (!Debug)
|
@ -8,6 +8,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_8_R3.NBTTagLong;
|
||||
@ -1289,4 +1290,87 @@ public class UtilItem
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isSimilar(ItemStack a, ItemStack b, ItemAttribute... attributes)
|
||||
{
|
||||
for (ItemAttribute attr : attributes)
|
||||
{
|
||||
if (!attr.isEqual(a, b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum ItemAttribute
|
||||
{
|
||||
MATERIAL
|
||||
{
|
||||
@Override
|
||||
public boolean isEqual(ItemStack a, ItemStack b)
|
||||
{
|
||||
return a == null ? b == null : b != null && a.getType() == b.getType();
|
||||
}
|
||||
},
|
||||
DATA
|
||||
{
|
||||
@Override
|
||||
public boolean isEqual(ItemStack a, ItemStack b)
|
||||
{
|
||||
return a == null ? b == null : b != null && a.getData().getData() == b.getData().getData();
|
||||
}
|
||||
},
|
||||
AMOUNT
|
||||
{
|
||||
@Override
|
||||
public boolean isEqual(ItemStack a, ItemStack b)
|
||||
{
|
||||
return a == null ? b == null : b != null && a.getAmount() == b.getAmount();
|
||||
}
|
||||
},
|
||||
NAME
|
||||
{
|
||||
@Override
|
||||
public boolean isEqual(ItemStack a, ItemStack b)
|
||||
{
|
||||
if (a == null)
|
||||
{
|
||||
return b == null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (b == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ItemMeta ma = a.getItemMeta();
|
||||
ItemMeta mb = b.getItemMeta();
|
||||
if (ma == null)
|
||||
{
|
||||
return mb == null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mb == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return Objects.equals(ma.getDisplayName(), mb.getDisplayName());
|
||||
}
|
||||
},
|
||||
LORE
|
||||
{
|
||||
@Override
|
||||
public boolean isEqual(ItemStack a, ItemStack b)
|
||||
{
|
||||
return a == null ? b == null : b != null && Objects.equals(a.getItemMeta().getLore(), b.getItemMeta().getLore());
|
||||
}
|
||||
};
|
||||
|
||||
public abstract boolean isEqual(ItemStack a, ItemStack b);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ public class UtilParser
|
||||
{
|
||||
public static String parseDamageCause(EntityDamageEvent.DamageCause cause)
|
||||
{
|
||||
if (cause == null)
|
||||
return "Unknown";
|
||||
switch (cause)
|
||||
{
|
||||
case CONTACT:
|
||||
|
@ -140,8 +140,44 @@ public class UtilServer
|
||||
return getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing");
|
||||
}
|
||||
|
||||
public static boolean isDevServer()
|
||||
{
|
||||
return !isTestServer() && isDevServer(getServerName());
|
||||
}
|
||||
|
||||
public static boolean isDevServer(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
int index = name.lastIndexOf('-');
|
||||
if (index != -1)
|
||||
{
|
||||
int id = Integer.parseInt(name.substring(index + 1));
|
||||
return id >= 777;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isHubServer()
|
||||
{
|
||||
return getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Lobby");
|
||||
}
|
||||
|
||||
public static void raiseError(RuntimeException throwable)
|
||||
{
|
||||
if (isTestServer())
|
||||
{
|
||||
throw throwable;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("ERROR WAS RAISED");
|
||||
throwable.printStackTrace(System.out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -151,11 +152,21 @@ public abstract class MiniPlugin implements Listener
|
||||
return _plugin.getServer().getScheduler().runTaskLater(_plugin, runnable, delay);
|
||||
}
|
||||
|
||||
public BukkitTask runSyncLater(BukkitRunnable runnable, long delay)
|
||||
{
|
||||
return runnable.runTaskLater(_plugin, delay);
|
||||
}
|
||||
|
||||
public BukkitTask runSyncTimer(Runnable runnable, long delay, long period)
|
||||
{
|
||||
return _plugin.getServer().getScheduler().runTaskTimer(_plugin, runnable, delay, period);
|
||||
}
|
||||
|
||||
public BukkitTask runSyncTimer(BukkitRunnable runnable, long delay, long period)
|
||||
{
|
||||
return runnable.runTaskTimer(_plugin, delay, period);
|
||||
}
|
||||
|
||||
protected <T extends MiniPlugin> T require(Class<T> clazz)
|
||||
{
|
||||
return Managers.require(clazz);
|
||||
|
@ -30,7 +30,7 @@ import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTasks;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
|
@ -47,8 +47,20 @@ public enum AchievementCategory
|
||||
|
||||
UHC("Ultra Hardcore", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None", false, GameDisplay.UHC.getGameId()),
|
||||
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHC.getGameId()),
|
||||
|
||||
UHC_SOLO("Ultra Hardcore Solo", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSolo.getGameId()),
|
||||
|
||||
UHC_SOLO_SPPED("Ultra Hardcore Solo Speed", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSoloSpeed.getGameId()),
|
||||
|
||||
UHC_TEAMS_SPPED("Ultra Hardcore Teams Speed", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCTeamsSpeed.getGameId()),
|
||||
|
||||
/*MC_LEAGUE("MC League", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.IRON_CHESTPLATE, 0, GameCategory.SURVIVAL, "None", true, GameDisplay.Minecraft_League.getGameId()),*/
|
||||
@ -335,6 +347,6 @@ public enum AchievementCategory
|
||||
|
||||
public enum GameCategory
|
||||
{
|
||||
GLOBAL, HOLIDAY, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE
|
||||
GLOBAL, HOLIDAY, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE, UHC
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
package mineplex.core.achievement.ui.button;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.achievement.ui.AchievementShop;
|
||||
import mineplex.core.achievement.ui.page.UHCMainPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class UHCButton implements IButton
|
||||
{
|
||||
private AchievementShop _shop;
|
||||
private AchievementManager _achievementManager;
|
||||
private StatsManager _statsManager;
|
||||
private DonationManager _donationManager;
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
private String _targetName;
|
||||
private PlayerStats _targetStats;
|
||||
|
||||
public UHCButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, DonationManager donationManager, CoreClientManager clientManager, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
_shop = shop;
|
||||
_achievementManager = achievementManager;
|
||||
_statsManager = statsManager;
|
||||
_donationManager = donationManager;
|
||||
_clientManager = clientManager;
|
||||
|
||||
_targetName = targetName;
|
||||
_targetStats = targetStats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_shop.openPageForPlayer(player, new UHCMainPage(_achievementManager, _statsManager, _shop, _clientManager, _donationManager, "UHC", player, _targetName, _targetStats));
|
||||
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,6 @@ package mineplex.core.achievement.ui.page;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -16,11 +15,13 @@ import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.achievement.ui.AchievementShop;
|
||||
import mineplex.core.achievement.ui.button.ArcadeButton;
|
||||
import mineplex.core.achievement.ui.button.CategoryButton;
|
||||
import mineplex.core.achievement.ui.button.UHCButton;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemLayout;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class AchievementMainPage extends ShopPageBase<AchievementManager, AchievementShop>
|
||||
@ -59,7 +60,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
|
||||
for (AchievementCategory category : AchievementCategory.values())
|
||||
{
|
||||
if (category.getGameCategory() == AchievementCategory.GameCategory.ARCADE)
|
||||
if (category.getGameCategory() == AchievementCategory.GameCategory.ARCADE || category.getGameCategory() == AchievementCategory.GameCategory.UHC)
|
||||
continue;
|
||||
|
||||
CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(),
|
||||
@ -79,6 +80,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
}
|
||||
|
||||
addArcadeButton(pageLayout.get(listSlot++));
|
||||
addUHCButton(pageLayout.get(listSlot++));
|
||||
}
|
||||
|
||||
protected void addArcadeButton(int slot)
|
||||
@ -88,6 +90,14 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
|
||||
addButton(slot, shopItem, button);
|
||||
}
|
||||
|
||||
protected void addUHCButton(int slot)
|
||||
{
|
||||
UHCButton button = new UHCButton(getShop(), getPlugin(), _statsManager, getDonationManager(), getClientManager(), _targetName, _targetStats);
|
||||
ShopItem shopItem = new ShopItem(Material.GOLDEN_APPLE, (byte) 0, C.Bold + "UHC", new String[] {" ", ChatColor.RESET + "Click for more!"}, 1, false, false);
|
||||
|
||||
addButton(slot, shopItem, button);
|
||||
}
|
||||
|
||||
protected void addAchievements(AchievementCategory category, List<String> lore, int max)
|
||||
{
|
||||
|
@ -0,0 +1,71 @@
|
||||
package mineplex.core.achievement.ui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementCategory;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.achievement.ui.AchievementShop;
|
||||
import mineplex.core.achievement.ui.button.CategoryButton;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class UHCMainPage extends AchievementMainPage
|
||||
{
|
||||
public UHCMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
super(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 5, targetName, targetStats);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int slot = 10;
|
||||
|
||||
for (AchievementCategory category : AchievementCategory.values())
|
||||
{
|
||||
if (category.getGameCategory() != AchievementCategory.GameCategory.UHC)
|
||||
continue;
|
||||
|
||||
CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), getClientManager(), _targetName, _targetStats);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add(" ");
|
||||
category.addStats(getClientManager(), _statsManager, lore, 2, getPlayer(), _targetName, _targetStats);
|
||||
lore.add(" ");
|
||||
addAchievements(category, lore, 9);
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Click for more details!");
|
||||
|
||||
ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), lore.toArray(new String[0]), 1, false, false);
|
||||
addButton(slot, shopItem, button);
|
||||
|
||||
slot += ((slot + 1) % 9 == 0) ? 1 : 2;
|
||||
}
|
||||
|
||||
addBackButton();
|
||||
}
|
||||
|
||||
private void addBackButton()
|
||||
{
|
||||
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
getShop().openPageForPlayer(getPlayer(), new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _targetName + "'s Stats", player, _targetName, _targetStats));
|
||||
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -143,8 +143,6 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
private List<AntiHackGuardian> _guardians = new ArrayList<>();
|
||||
|
||||
private Predicate<Player> _filter = player -> true;
|
||||
|
||||
private Set<Player> _pendingBan = new HashSet<>();
|
||||
|
||||
// These are the GWEN checks to ignore when handling PlayerViolationEvent
|
||||
@ -276,8 +274,7 @@ public class AntiHack extends MiniPlugin
|
||||
Rank.LT
|
||||
),
|
||||
player -> !_stalking.contains(player.getUniqueId()),
|
||||
player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null,
|
||||
_filter
|
||||
player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null
|
||||
));
|
||||
|
||||
while (_stalking.size() < MAX_STALKED_PLAYERS && targets.size() > 0)
|
||||
@ -444,18 +441,6 @@ public class AntiHack extends MiniPlugin
|
||||
);
|
||||
}
|
||||
|
||||
public void registerFilter(Predicate<Player> filter)
|
||||
{
|
||||
if (filter == null)
|
||||
{
|
||||
this._filter = player -> true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._filter = filter;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerGuardian(AntiHackGuardian guardian)
|
||||
{
|
||||
this._guardians.add(guardian);
|
||||
|
@ -54,6 +54,11 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
|
||||
{
|
||||
return _requiredRank;
|
||||
}
|
||||
|
||||
public void setRequiredRank(Rank rank)
|
||||
{
|
||||
this._requiredRank = rank;
|
||||
}
|
||||
|
||||
public Rank[] GetSpecificRanks()
|
||||
{
|
||||
|
@ -1,281 +1,281 @@
|
||||
package mineplex.core.gadget.gadgets.morph;
|
||||
|
||||
import java.time.Month;
|
||||
import java.time.YearMonth;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.SantaPresent;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.utils.UtilGameProfile;
|
||||
|
||||
public class MorphSanta extends MorphGadget
|
||||
{
|
||||
|
||||
private HashMap<Item, SantaPresent> _items = new HashMap<>();
|
||||
|
||||
private static final int SHARD_CHARGE = 50;
|
||||
|
||||
public MorphSanta(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Santa Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableCustom(Player player, boolean message)
|
||||
{
|
||||
applyArmor(player, message);
|
||||
|
||||
GameProfile profile = UtilGameProfile.getGameProfile(player);
|
||||
profile.getProperties().clear();
|
||||
profile.getProperties().put("textures", SkinData.SANTA.getProperty());
|
||||
|
||||
DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile);
|
||||
disguisePlayer.showInTabList(true, 0);
|
||||
UtilMorph.disguise(player, disguisePlayer, Manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableCustom(Player player, boolean message)
|
||||
{
|
||||
removeArmor(player);
|
||||
|
||||
UtilMorph.undisguise(player, Manager.getDisguiseManager());
|
||||
}
|
||||
|
||||
// PRESENT
|
||||
|
||||
@EventHandler
|
||||
public void throwPresent(PlayerInteractEvent event)
|
||||
{
|
||||
if (!isActive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (!UtilEvent.isAction(event, UtilEvent.ActionType.L))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
int type = 0;
|
||||
|
||||
if (UtilMath.random(0.1, 1.1) > 0.76)
|
||||
{
|
||||
type = 1;
|
||||
}
|
||||
|
||||
if (player.getItemInHand().getType() != Material.AIR)
|
||||
return;
|
||||
|
||||
//if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics"))
|
||||
//return;
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
int shards = UtilMath.rRange(250, 500);
|
||||
|
||||
if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) < shards + SHARD_CHARGE)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards."));
|
||||
return;
|
||||
}
|
||||
|
||||
Item present = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),
|
||||
SkinData.PRESENT.getSkull("Present " + System.currentTimeMillis(), new ArrayList<>()));
|
||||
UtilAction.velocity(present, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
|
||||
|
||||
Manager.getDonationManager().RewardCoinsLater(this.getName() + " Present Hide", player, -(shards + SHARD_CHARGE));
|
||||
|
||||
present.setPickupDelay(40);
|
||||
|
||||
_items.put(present, new SantaPresent(player.getName(), SantaPresent.PresentType.PRESENT, shards));
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
|
||||
ChatColor.RESET + C.Bold + " hid a " +
|
||||
C.cRed + C.Bold + "Christmas Present" +
|
||||
ChatColor.RESET + C.Bold + " worth " +
|
||||
C.cRed + C.Bold + shards + " Shards");
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
other.playSound(other.getLocation(), Sound.BLAZE_HIT, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack coalStack = ItemStackFactory.Instance.CreateStack(Material.COAL, (byte)0, 1, "Hidden Coal" + System.currentTimeMillis());
|
||||
Item coal = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), coalStack);
|
||||
UtilAction.velocity(coal, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
|
||||
|
||||
int coals = UtilMath.rRange(1, 3);
|
||||
|
||||
coal.setPickupDelay(40);
|
||||
|
||||
_items.put(coal, new SantaPresent(player.getName(), SantaPresent.PresentType.COAL, coals));
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
|
||||
ChatColor.RESET + C.Bold + " hid a " +
|
||||
C.cRed + C.Bold + "Christmas Coal" +
|
||||
ChatColor.RESET + C.Bold + " worth " +
|
||||
C.cRed + C.Bold + coals + " Coal Ammo");
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
other.playSound(other.getLocation(), Sound.DIG_SNOW, 1.5f, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void presentPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (_items.containsKey(event.getItem()) && !_items.get(event.getItem()).getThrower().equals(event.getPlayer().getName()))
|
||||
{
|
||||
SantaPresent santaPresent = _items.get(event.getItem());
|
||||
|
||||
_items.remove(event.getItem());
|
||||
|
||||
event.setCancelled(true);
|
||||
event.getItem().remove();
|
||||
|
||||
int presentsLeft = 0, coalsLeft = 0;
|
||||
for (SantaPresent present : _items.values())
|
||||
{
|
||||
if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
presentsLeft++;
|
||||
}
|
||||
else if (present.getPresentType().equals(SantaPresent.PresentType.COAL))
|
||||
{
|
||||
coalsLeft++;
|
||||
}
|
||||
}
|
||||
|
||||
if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
Manager.getDonationManager().RewardCoinsLater(getName() + " Present Pickup", event.getPlayer(), santaPresent.getAmmo());
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() +
|
||||
ChatColor.RESET + C.Bold + " found a " +
|
||||
C.cGold + C.Bold + "Christmas Present" +
|
||||
ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!");
|
||||
}
|
||||
else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL))
|
||||
{
|
||||
// Gives coals
|
||||
Manager.getInventoryManager().addItemToInventory(event.getPlayer(), "Coal", santaPresent.getAmmo());
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() +
|
||||
ChatColor.RESET + C.Bold + " found a " +
|
||||
C.cGold + C.Bold + "Christmas Coal" +
|
||||
ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!");
|
||||
}
|
||||
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 0.75f);
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 1.25f);
|
||||
|
||||
UtilFirework.playFirework(event.getItem().getLocation(), FireworkEffect.Type.BURST, Color.RED, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void presentClean(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
Iterator<Item> presentIter = _items.keySet().iterator();
|
||||
|
||||
while (presentIter.hasNext())
|
||||
{
|
||||
Item presentItem = presentIter.next();
|
||||
|
||||
if (!presentItem.isValid() || presentItem.getTicksLived() > 24000)
|
||||
{
|
||||
SantaPresent santaPresent = _items.get(presentItem);
|
||||
|
||||
presentItem.remove();
|
||||
presentIter.remove();
|
||||
|
||||
//Announce
|
||||
if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
int presentsLeft = 0;
|
||||
for (SantaPresent present : _items.values())
|
||||
{
|
||||
if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
presentsLeft++;
|
||||
}
|
||||
}
|
||||
Bukkit.broadcastMessage(
|
||||
ChatColor.RESET + C.Bold + "No one found a " +
|
||||
C.cGold + C.Bold + "Christmas Present" +
|
||||
ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!");
|
||||
}
|
||||
else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL))
|
||||
{
|
||||
int coalsLeft = 0;
|
||||
for (SantaPresent present : _items.values())
|
||||
{
|
||||
if (present.getPresentType().equals(SantaPresent.PresentType.COAL))
|
||||
{
|
||||
coalsLeft++;
|
||||
}
|
||||
}
|
||||
Bukkit.broadcastMessage(
|
||||
ChatColor.RESET + C.Bold + "No one found a " +
|
||||
C.cGold + C.Bold + "Christmas Coal" +
|
||||
ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, presentItem.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1,
|
||||
UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void presentDespawnCancel(ItemDespawnEvent event)
|
||||
{
|
||||
if (_items.containsKey(event.getEntity()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
package mineplex.core.gadget.gadgets.morph;
|
||||
|
||||
import java.time.Month;
|
||||
import java.time.YearMonth;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.SantaPresent;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.utils.UtilGameProfile;
|
||||
|
||||
public class MorphSanta extends MorphGadget
|
||||
{
|
||||
|
||||
private HashMap<Item, SantaPresent> _items = new HashMap<>();
|
||||
|
||||
private static final int SHARD_CHARGE = 50;
|
||||
|
||||
public MorphSanta(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Santa Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableCustom(Player player, boolean message)
|
||||
{
|
||||
applyArmor(player, message);
|
||||
|
||||
GameProfile profile = UtilGameProfile.getGameProfile(player);
|
||||
profile.getProperties().clear();
|
||||
profile.getProperties().put("textures", SkinData.SANTA.getProperty());
|
||||
|
||||
DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile);
|
||||
disguisePlayer.showInTabList(true, 0);
|
||||
UtilMorph.disguise(player, disguisePlayer, Manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableCustom(Player player, boolean message)
|
||||
{
|
||||
removeArmor(player);
|
||||
|
||||
UtilMorph.undisguise(player, Manager.getDisguiseManager());
|
||||
}
|
||||
|
||||
// PRESENT
|
||||
|
||||
@EventHandler
|
||||
public void throwPresent(PlayerInteractEvent event)
|
||||
{
|
||||
if (!isActive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (!UtilEvent.isAction(event, UtilEvent.ActionType.L))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
int type = 0;
|
||||
|
||||
if (UtilMath.random(0.1, 1.1) > 0.76)
|
||||
{
|
||||
type = 1;
|
||||
}
|
||||
|
||||
if (player.getItemInHand().getType() != Material.AIR)
|
||||
return;
|
||||
|
||||
//if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics"))
|
||||
//return;
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
int shards = UtilMath.rRange(250, 500);
|
||||
|
||||
if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) < shards + SHARD_CHARGE)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards."));
|
||||
return;
|
||||
}
|
||||
|
||||
Item present = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),
|
||||
SkinData.PRESENT.getSkull("Present " + System.currentTimeMillis(), new ArrayList<>()));
|
||||
UtilAction.velocity(present, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
|
||||
|
||||
Manager.getDonationManager().RewardCoinsLater(this.getName() + " Present Hide", player, -(shards + SHARD_CHARGE));
|
||||
|
||||
present.setPickupDelay(40);
|
||||
|
||||
_items.put(present, new SantaPresent(player.getName(), SantaPresent.PresentType.PRESENT, shards));
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
|
||||
ChatColor.RESET + C.Bold + " hid a " +
|
||||
C.cRed + C.Bold + "Christmas Present" +
|
||||
ChatColor.RESET + C.Bold + " worth " +
|
||||
C.cRed + C.Bold + shards + " Shards");
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
other.playSound(other.getLocation(), Sound.BLAZE_HIT, 1.5f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack coalStack = ItemStackFactory.Instance.CreateStack(Material.COAL, (byte)0, 1, "Hidden Coal" + System.currentTimeMillis());
|
||||
Item coal = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), coalStack);
|
||||
UtilAction.velocity(coal, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
|
||||
|
||||
int coals = UtilMath.rRange(1, 3);
|
||||
|
||||
coal.setPickupDelay(40);
|
||||
|
||||
_items.put(coal, new SantaPresent(player.getName(), SantaPresent.PresentType.COAL, coals));
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
|
||||
ChatColor.RESET + C.Bold + " hid a " +
|
||||
C.cRed + C.Bold + "Christmas Coal" +
|
||||
ChatColor.RESET + C.Bold + " worth " +
|
||||
C.cRed + C.Bold + coals + " Coal Ammo");
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
other.playSound(other.getLocation(), Sound.DIG_SNOW, 1.5f, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void presentPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (_items.containsKey(event.getItem()) && !_items.get(event.getItem()).getThrower().equals(event.getPlayer().getName()))
|
||||
{
|
||||
SantaPresent santaPresent = _items.get(event.getItem());
|
||||
|
||||
_items.remove(event.getItem());
|
||||
|
||||
event.setCancelled(true);
|
||||
event.getItem().remove();
|
||||
|
||||
int presentsLeft = 0, coalsLeft = 0;
|
||||
for (SantaPresent present : _items.values())
|
||||
{
|
||||
if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
presentsLeft++;
|
||||
}
|
||||
else if (present.getPresentType().equals(SantaPresent.PresentType.COAL))
|
||||
{
|
||||
coalsLeft++;
|
||||
}
|
||||
}
|
||||
|
||||
if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
Manager.getDonationManager().RewardCoinsLater(getName() + " Present Pickup", event.getPlayer(), santaPresent.getAmmo());
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() +
|
||||
ChatColor.RESET + C.Bold + " found a " +
|
||||
C.cGold + C.Bold + "Christmas Present" +
|
||||
ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!");
|
||||
}
|
||||
else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL))
|
||||
{
|
||||
// Gives coals
|
||||
Manager.getInventoryManager().addItemToInventory(event.getPlayer(), "Coal", santaPresent.getAmmo());
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() +
|
||||
ChatColor.RESET + C.Bold + " found a " +
|
||||
C.cGold + C.Bold + "Christmas Coal" +
|
||||
ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!");
|
||||
}
|
||||
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 0.75f);
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 1.25f);
|
||||
|
||||
UtilFirework.playFirework(event.getItem().getLocation(), FireworkEffect.Type.BURST, Color.RED, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void presentClean(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
Iterator<Item> presentIter = _items.keySet().iterator();
|
||||
|
||||
while (presentIter.hasNext())
|
||||
{
|
||||
Item presentItem = presentIter.next();
|
||||
|
||||
if (!presentItem.isValid() || presentItem.getTicksLived() > 24000)
|
||||
{
|
||||
SantaPresent santaPresent = _items.get(presentItem);
|
||||
|
||||
presentItem.remove();
|
||||
presentIter.remove();
|
||||
|
||||
//Announce
|
||||
if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
int presentsLeft = 0;
|
||||
for (SantaPresent present : _items.values())
|
||||
{
|
||||
if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT))
|
||||
{
|
||||
presentsLeft++;
|
||||
}
|
||||
}
|
||||
Bukkit.broadcastMessage(
|
||||
ChatColor.RESET + C.Bold + "No one found a " +
|
||||
C.cGold + C.Bold + "Christmas Present" +
|
||||
ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!");
|
||||
}
|
||||
else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL))
|
||||
{
|
||||
int coalsLeft = 0;
|
||||
for (SantaPresent present : _items.values())
|
||||
{
|
||||
if (present.getPresentType().equals(SantaPresent.PresentType.COAL))
|
||||
{
|
||||
coalsLeft++;
|
||||
}
|
||||
}
|
||||
Bukkit.broadcastMessage(
|
||||
ChatColor.RESET + C.Bold + "No one found a " +
|
||||
C.cGold + C.Bold + "Christmas Coal" +
|
||||
ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, presentItem.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1,
|
||||
UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void presentDespawnCancel(ItemDespawnEvent event)
|
||||
{
|
||||
if (_items.containsKey(event.getEntity()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,128 +1,128 @@
|
||||
package mineplex.core.gadget.gadgets.morph;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.disguise.disguises.DisguiseSquid;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
/**
|
||||
* THIS MORPH IS 1.9+ ONLY
|
||||
*/
|
||||
public class MorphStray extends MorphGadget
|
||||
{
|
||||
|
||||
private List<Arrow> _strayArrows = new ArrayList<>();
|
||||
private ItemStack _arrow;
|
||||
|
||||
public MorphStray(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Stray Morph", UtilText.splitLinesToArray(new String[]{
|
||||
C.cGray + "Even though it's a stray your mom probably won't let you keep this puppy.",
|
||||
"",
|
||||
C.cWhite + "Gains an arrow every 5 seconds with EXTREME knockback."
|
||||
}, LineFormat.LORE),
|
||||
0, Material.BARRIER, (byte) 0);
|
||||
_arrow = ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte) 0, 1, C.cGreen + "Stray Arrow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableCustom(Player player, boolean message)
|
||||
{
|
||||
// TODO CHECK IF LOBBY IS 1.9+
|
||||
applyArmor(player, message);
|
||||
DisguiseSquid disguiseSquid = new DisguiseSquid(player);
|
||||
UtilMorph.disguise(player, disguiseSquid, Manager);
|
||||
|
||||
// Gives bow and arrow
|
||||
ItemStack bow = ItemStackFactory.Instance.CreateStack(Material.BOW, (byte) 0, 1, C.cGreen + "Stray Bow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE));
|
||||
player.getInventory().setItem(2, bow);
|
||||
player.getInventory().setItem(17, _arrow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableCustom(Player player, boolean message)
|
||||
{
|
||||
removeArmor(player);
|
||||
UtilMorph.undisguise(player, Manager.getDisguiseManager());
|
||||
|
||||
// Removes bow and arrow
|
||||
player.getInventory().setItem(2, new ItemStack(Material.AIR));
|
||||
player.getInventory().setItem(17, new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onShoot(EntityShootBowEvent event)
|
||||
{
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!(event.getProjectile() instanceof Arrow))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!isActive(player))
|
||||
return;
|
||||
|
||||
_strayArrows.add((Arrow) event.getProjectile());
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.getInventory().setItem(17, _arrow);
|
||||
}
|
||||
}, 3 * 20L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onArrowHitPlayer(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!(event.getDamager() instanceof Arrow))
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!(((Arrow) event.getDamager()).getShooter() instanceof Player))
|
||||
return;
|
||||
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!_strayArrows.contains(arrow))
|
||||
return;
|
||||
|
||||
_strayArrows.remove(arrow);
|
||||
|
||||
Player shooter = (Player) arrow.getShooter();
|
||||
arrow.remove();
|
||||
|
||||
if (shooter.getUniqueId().equals(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
player.setVelocity(player.getVelocity().multiply(-15).setY(15));
|
||||
UtilPlayer.message(player, F.main("Stray Arrow", "You were hit with a " + F.greenElem("Stray Arrow") + " from " + F.name(shooter.getName()) + " and got knocked back!"));
|
||||
UtilPlayer.message(shooter, F.main("Stray Arrow", "You hit " + F.name(player.getName()) + " with the " + F.greenElem("Stray Arrow") + " and they got knocked back!"));
|
||||
}
|
||||
|
||||
}
|
||||
package mineplex.core.gadget.gadgets.morph;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.disguise.disguises.DisguiseSquid;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
/**
|
||||
* THIS MORPH IS 1.9+ ONLY
|
||||
*/
|
||||
public class MorphStray extends MorphGadget
|
||||
{
|
||||
|
||||
private List<Arrow> _strayArrows = new ArrayList<>();
|
||||
private ItemStack _arrow;
|
||||
|
||||
public MorphStray(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Stray Morph", UtilText.splitLinesToArray(new String[]{
|
||||
C.cGray + "Even though it's a stray your mom probably won't let you keep this puppy.",
|
||||
"",
|
||||
C.cWhite + "Gains an arrow every 5 seconds with EXTREME knockback."
|
||||
}, LineFormat.LORE),
|
||||
0, Material.BARRIER, (byte) 0);
|
||||
_arrow = ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte) 0, 1, C.cGreen + "Stray Arrow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableCustom(Player player, boolean message)
|
||||
{
|
||||
// TODO CHECK IF LOBBY IS 1.9+
|
||||
applyArmor(player, message);
|
||||
DisguiseSquid disguiseSquid = new DisguiseSquid(player);
|
||||
UtilMorph.disguise(player, disguiseSquid, Manager);
|
||||
|
||||
// Gives bow and arrow
|
||||
ItemStack bow = ItemStackFactory.Instance.CreateStack(Material.BOW, (byte) 0, 1, C.cGreen + "Stray Bow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE));
|
||||
player.getInventory().setItem(2, bow);
|
||||
player.getInventory().setItem(17, _arrow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableCustom(Player player, boolean message)
|
||||
{
|
||||
removeArmor(player);
|
||||
UtilMorph.undisguise(player, Manager.getDisguiseManager());
|
||||
|
||||
// Removes bow and arrow
|
||||
player.getInventory().setItem(2, new ItemStack(Material.AIR));
|
||||
player.getInventory().setItem(17, new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onShoot(EntityShootBowEvent event)
|
||||
{
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!(event.getProjectile() instanceof Arrow))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!isActive(player))
|
||||
return;
|
||||
|
||||
_strayArrows.add((Arrow) event.getProjectile());
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.getInventory().setItem(17, _arrow);
|
||||
}
|
||||
}, 3 * 20L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onArrowHitPlayer(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!(event.getDamager() instanceof Arrow))
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!(((Arrow) event.getDamager()).getShooter() instanceof Player))
|
||||
return;
|
||||
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!_strayArrows.contains(arrow))
|
||||
return;
|
||||
|
||||
_strayArrows.remove(arrow);
|
||||
|
||||
Player shooter = (Player) arrow.getShooter();
|
||||
arrow.remove();
|
||||
|
||||
if (shooter.getUniqueId().equals(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
player.setVelocity(player.getVelocity().multiply(-15).setY(15));
|
||||
UtilPlayer.message(player, F.main("Stray Arrow", "You were hit with a " + F.greenElem("Stray Arrow") + " from " + F.name(shooter.getName()) + " and got knocked back!"));
|
||||
UtilPlayer.message(shooter, F.main("Stray Arrow", "You hit " + F.name(player.getName()) + " with the " + F.greenElem("Stray Arrow") + " and they got knocked back!"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,38 +1,38 @@
|
||||
package mineplex.core.gadget.gadgets.morph.managers;
|
||||
|
||||
public class SantaPresent
|
||||
{
|
||||
|
||||
public enum PresentType
|
||||
{
|
||||
PRESENT,
|
||||
COAL
|
||||
}
|
||||
|
||||
private final String _thrower;
|
||||
private final PresentType _presentType;
|
||||
private final int _ammo;
|
||||
|
||||
public SantaPresent(String thrower, PresentType presentType, int ammo)
|
||||
{
|
||||
_thrower = thrower;
|
||||
_presentType = presentType;
|
||||
_ammo = ammo;
|
||||
}
|
||||
|
||||
public String getThrower()
|
||||
{
|
||||
return _thrower;
|
||||
}
|
||||
|
||||
public PresentType getPresentType()
|
||||
{
|
||||
return _presentType;
|
||||
}
|
||||
|
||||
public int getAmmo()
|
||||
{
|
||||
return _ammo;
|
||||
}
|
||||
|
||||
}
|
||||
package mineplex.core.gadget.gadgets.morph.managers;
|
||||
|
||||
public class SantaPresent
|
||||
{
|
||||
|
||||
public enum PresentType
|
||||
{
|
||||
PRESENT,
|
||||
COAL
|
||||
}
|
||||
|
||||
private final String _thrower;
|
||||
private final PresentType _presentType;
|
||||
private final int _ammo;
|
||||
|
||||
public SantaPresent(String thrower, PresentType presentType, int ammo)
|
||||
{
|
||||
_thrower = thrower;
|
||||
_presentType = presentType;
|
||||
_ammo = ammo;
|
||||
}
|
||||
|
||||
public String getThrower()
|
||||
{
|
||||
return _thrower;
|
||||
}
|
||||
|
||||
public PresentType getPresentType()
|
||||
{
|
||||
return _presentType;
|
||||
}
|
||||
|
||||
public int getAmmo()
|
||||
{
|
||||
return _ammo;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,7 +56,10 @@ public enum GameDisplay
|
||||
SurvivalGamesTeams("Survival Games Teams", "Survival Games", Material.IRON_SWORD, (byte)0, GameCategory.TEAM_VARIANT, 23),
|
||||
Tug("Tug of Wool", Material.WHEAT, (byte)0, GameCategory.ARCADE, 44),
|
||||
TurfWars("Turf Wars", Material.STAINED_CLAY, (byte)14, GameCategory.ARCADE, 45),
|
||||
UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46),
|
||||
UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.TEAM_VARIANT, 46),
|
||||
UHCSolo("Ultra Hardcore Solo", "Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46),
|
||||
UHCSoloSpeed("Ultra Hardcore Solo Speed", "Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 67),
|
||||
UHCTeamsSpeed("Ultra Hardcore Teams Speed", "Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.TEAM_VARIANT, 67),
|
||||
WitherAssault("Wither Assault", Material.SKULL_ITEM, (byte)1, GameCategory.ARCADE, 47),
|
||||
Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48),
|
||||
ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49),
|
||||
|
@ -1,155 +1,155 @@
|
||||
package mineplex.core.particleeffects;
|
||||
|
||||
public class NewYearEffect //extends Effect
|
||||
{
|
||||
|
||||
/*private static final int SECONDS_IN_A_MINUTE = 60;
|
||||
|
||||
private final Location _ballLocation, _clockLocation, _timerLocation, _timerLocationTen;
|
||||
|
||||
private int _seconds = 90;
|
||||
private Collection<Block> _blocks = new ArrayList<>();
|
||||
private List<Schematic> _schematics = new ArrayList<>();
|
||||
private boolean _placed = false;
|
||||
private int _currentRun = 0;
|
||||
|
||||
public NewYearEffect(JavaPlugin plugin, Location location)
|
||||
{
|
||||
super(-1, new EffectLocation(location), plugin, 10);
|
||||
_ballLocation = new Location(location.clone().getWorld(), 0, 71, 38);
|
||||
_clockLocation = _ballLocation.clone().add(-12, 0, -15);
|
||||
_timerLocation = _clockLocation.clone().add(19, 7, 0);
|
||||
_timerLocationTen = _timerLocation.clone().add(1, 0, 0);
|
||||
try
|
||||
{
|
||||
for (int i = 0; i <= 10; i++)
|
||||
{
|
||||
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearBall" + i + ".schematic"));
|
||||
_schematics.add(i, schematic);
|
||||
}
|
||||
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearClock.schematic"));
|
||||
_schematics.add(11, schematic);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEffect()
|
||||
{
|
||||
if (!_placed)
|
||||
{
|
||||
pasteSchematic(10, true);
|
||||
_placed = true;
|
||||
}
|
||||
|
||||
if (_seconds == -60)
|
||||
{
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_seconds == 0)
|
||||
{
|
||||
List<int[]> fireworkLocations = new ArrayList<>();
|
||||
List<int[]> fixedFireworkLocations = new ArrayList<>();
|
||||
int[][] fireworkCoords = new int[][]
|
||||
{
|
||||
{0, 77, -37},
|
||||
{-6, 71, 17},
|
||||
{6, 71, 17},
|
||||
{12, 71, 7},
|
||||
{-12, 71, 7},
|
||||
{5, 71, 92},
|
||||
{-7, 71, 92},
|
||||
{-9, 103, 37},
|
||||
{13, 107, 40}
|
||||
};
|
||||
fireworkLocations.addAll(Arrays.asList(fireworkCoords));
|
||||
int[][] fixedFireworkCoords = new int[][]
|
||||
{
|
||||
{0, 80, 0},
|
||||
{0, 80, -32},
|
||||
{6, 80, -26},
|
||||
{-6, 80, -26}
|
||||
};
|
||||
fixedFireworkLocations.addAll(Arrays.asList(fixedFireworkCoords));
|
||||
NewYearFireworkEffect newYearFireworkEffect = new NewYearFireworkEffect(_javaPlugin, fireworkLocations, fixedFireworkLocations, getEffectLocation().getFixedLocation().getWorld());
|
||||
newYearFireworkEffect.start();
|
||||
}
|
||||
|
||||
if (_currentRun % 2 != 0 && _seconds >= 0)
|
||||
{
|
||||
//Format seconds
|
||||
int totalMinutes = 0, totalSeconds = 0, placeholder;
|
||||
placeholder = _seconds;
|
||||
if (_seconds > SECONDS_IN_A_MINUTE)
|
||||
{
|
||||
while (placeholder > SECONDS_IN_A_MINUTE)
|
||||
{
|
||||
totalMinutes++;
|
||||
placeholder -= SECONDS_IN_A_MINUTE;
|
||||
}
|
||||
}
|
||||
totalSeconds = placeholder;
|
||||
String formatted = String.format("%02d:%02d", totalMinutes, totalSeconds);
|
||||
if (_seconds <= 10)
|
||||
{
|
||||
formatted = "| " + _seconds + " |";
|
||||
pasteSchematic(_seconds, false);
|
||||
}
|
||||
updateTimer(formatted, (byte) 0);
|
||||
_seconds--;
|
||||
}
|
||||
else if (_seconds >= 0 && _seconds <= 10)
|
||||
{
|
||||
updateTimer("| " + _seconds + " |", (byte) 14);
|
||||
}
|
||||
else if (_currentRun % 2 != 0 && _seconds < 0)
|
||||
{
|
||||
updateTimer("2017!", (byte) 0);
|
||||
_seconds--;
|
||||
}
|
||||
else if (_seconds < 0)
|
||||
{
|
||||
updateTimer("2017!", (byte) 14);
|
||||
}
|
||||
|
||||
_currentRun++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
_blocks.forEach(b -> b.setType(Material.AIR));
|
||||
_blocks.clear();
|
||||
updateTimer("2017!", (byte) 14);
|
||||
}
|
||||
|
||||
private void pasteSchematic(int second, boolean pasteClock)
|
||||
{
|
||||
Schematic schematic = _schematics.get(second);
|
||||
if (schematic != null)
|
||||
{
|
||||
schematic.paste(_ballLocation, false, true);
|
||||
|
||||
if (pasteClock)
|
||||
{
|
||||
Schematic clockSchematic = _schematics.get(11);
|
||||
clockSchematic.paste(_clockLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTimer(String time, byte color)
|
||||
{
|
||||
// Clears previous blocks
|
||||
_blocks.forEach(b -> b.setType(Material.AIR));
|
||||
|
||||
Collection<Block> blocks = UtilBlockText.MakeText(time, (_seconds <= 10 && _seconds >= 0) ? _timerLocationTen : _timerLocation, BlockFace.WEST, Material.STAINED_CLAY.getId(), color, UtilBlockText.TextAlign.LEFT, false);
|
||||
_blocks = blocks;
|
||||
}*/
|
||||
|
||||
}
|
||||
package mineplex.core.particleeffects;
|
||||
|
||||
public class NewYearEffect //extends Effect
|
||||
{
|
||||
|
||||
/*private static final int SECONDS_IN_A_MINUTE = 60;
|
||||
|
||||
private final Location _ballLocation, _clockLocation, _timerLocation, _timerLocationTen;
|
||||
|
||||
private int _seconds = 90;
|
||||
private Collection<Block> _blocks = new ArrayList<>();
|
||||
private List<Schematic> _schematics = new ArrayList<>();
|
||||
private boolean _placed = false;
|
||||
private int _currentRun = 0;
|
||||
|
||||
public NewYearEffect(JavaPlugin plugin, Location location)
|
||||
{
|
||||
super(-1, new EffectLocation(location), plugin, 10);
|
||||
_ballLocation = new Location(location.clone().getWorld(), 0, 71, 38);
|
||||
_clockLocation = _ballLocation.clone().add(-12, 0, -15);
|
||||
_timerLocation = _clockLocation.clone().add(19, 7, 0);
|
||||
_timerLocationTen = _timerLocation.clone().add(1, 0, 0);
|
||||
try
|
||||
{
|
||||
for (int i = 0; i <= 10; i++)
|
||||
{
|
||||
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearBall" + i + ".schematic"));
|
||||
_schematics.add(i, schematic);
|
||||
}
|
||||
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearClock.schematic"));
|
||||
_schematics.add(11, schematic);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEffect()
|
||||
{
|
||||
if (!_placed)
|
||||
{
|
||||
pasteSchematic(10, true);
|
||||
_placed = true;
|
||||
}
|
||||
|
||||
if (_seconds == -60)
|
||||
{
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_seconds == 0)
|
||||
{
|
||||
List<int[]> fireworkLocations = new ArrayList<>();
|
||||
List<int[]> fixedFireworkLocations = new ArrayList<>();
|
||||
int[][] fireworkCoords = new int[][]
|
||||
{
|
||||
{0, 77, -37},
|
||||
{-6, 71, 17},
|
||||
{6, 71, 17},
|
||||
{12, 71, 7},
|
||||
{-12, 71, 7},
|
||||
{5, 71, 92},
|
||||
{-7, 71, 92},
|
||||
{-9, 103, 37},
|
||||
{13, 107, 40}
|
||||
};
|
||||
fireworkLocations.addAll(Arrays.asList(fireworkCoords));
|
||||
int[][] fixedFireworkCoords = new int[][]
|
||||
{
|
||||
{0, 80, 0},
|
||||
{0, 80, -32},
|
||||
{6, 80, -26},
|
||||
{-6, 80, -26}
|
||||
};
|
||||
fixedFireworkLocations.addAll(Arrays.asList(fixedFireworkCoords));
|
||||
NewYearFireworkEffect newYearFireworkEffect = new NewYearFireworkEffect(_javaPlugin, fireworkLocations, fixedFireworkLocations, getEffectLocation().getFixedLocation().getWorld());
|
||||
newYearFireworkEffect.start();
|
||||
}
|
||||
|
||||
if (_currentRun % 2 != 0 && _seconds >= 0)
|
||||
{
|
||||
//Format seconds
|
||||
int totalMinutes = 0, totalSeconds = 0, placeholder;
|
||||
placeholder = _seconds;
|
||||
if (_seconds > SECONDS_IN_A_MINUTE)
|
||||
{
|
||||
while (placeholder > SECONDS_IN_A_MINUTE)
|
||||
{
|
||||
totalMinutes++;
|
||||
placeholder -= SECONDS_IN_A_MINUTE;
|
||||
}
|
||||
}
|
||||
totalSeconds = placeholder;
|
||||
String formatted = String.format("%02d:%02d", totalMinutes, totalSeconds);
|
||||
if (_seconds <= 10)
|
||||
{
|
||||
formatted = "| " + _seconds + " |";
|
||||
pasteSchematic(_seconds, false);
|
||||
}
|
||||
updateTimer(formatted, (byte) 0);
|
||||
_seconds--;
|
||||
}
|
||||
else if (_seconds >= 0 && _seconds <= 10)
|
||||
{
|
||||
updateTimer("| " + _seconds + " |", (byte) 14);
|
||||
}
|
||||
else if (_currentRun % 2 != 0 && _seconds < 0)
|
||||
{
|
||||
updateTimer("2017!", (byte) 0);
|
||||
_seconds--;
|
||||
}
|
||||
else if (_seconds < 0)
|
||||
{
|
||||
updateTimer("2017!", (byte) 14);
|
||||
}
|
||||
|
||||
_currentRun++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
_blocks.forEach(b -> b.setType(Material.AIR));
|
||||
_blocks.clear();
|
||||
updateTimer("2017!", (byte) 14);
|
||||
}
|
||||
|
||||
private void pasteSchematic(int second, boolean pasteClock)
|
||||
{
|
||||
Schematic schematic = _schematics.get(second);
|
||||
if (schematic != null)
|
||||
{
|
||||
schematic.paste(_ballLocation, false, true);
|
||||
|
||||
if (pasteClock)
|
||||
{
|
||||
Schematic clockSchematic = _schematics.get(11);
|
||||
clockSchematic.paste(_clockLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTimer(String time, byte color)
|
||||
{
|
||||
// Clears previous blocks
|
||||
_blocks.forEach(b -> b.setType(Material.AIR));
|
||||
|
||||
Collection<Block> blocks = UtilBlockText.MakeText(time, (_seconds <= 10 && _seconds >= 0) ? _timerLocationTen : _timerLocation, BlockFace.WEST, Material.STAINED_CLAY.getId(), color, UtilBlockText.TextAlign.LEFT, false);
|
||||
_blocks = blocks;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
@ -1,46 +1,46 @@
|
||||
package mineplex.core.particleeffects;
|
||||
|
||||
public class NewYearFireworkEffect //extends Effect
|
||||
{
|
||||
|
||||
/*private static final int MAX_TICKS = 1200;
|
||||
|
||||
private List<Location> _locations = new ArrayList<>();
|
||||
private List<Location> _fixedLocations = new ArrayList<>();
|
||||
private int _ticks = 0;
|
||||
|
||||
public NewYearFireworkEffect(JavaPlugin plugin, List<int[]> locations, List<int[]> fixedLocations, World world)
|
||||
{
|
||||
super(-1, null, plugin, 5);
|
||||
for (int[] locCoords : locations)
|
||||
{
|
||||
_locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2]));
|
||||
}
|
||||
for (int[] locCoords : fixedLocations)
|
||||
{
|
||||
_locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2]));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEffect()
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
int r = UtilMath.random.nextInt(_locations.size() - 1);
|
||||
Location location = _locations.get(r);
|
||||
UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2),
|
||||
new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1);
|
||||
}
|
||||
for (Location location : _fixedLocations)
|
||||
{
|
||||
UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2),
|
||||
new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1);
|
||||
}
|
||||
_ticks += 5;
|
||||
if (_ticks >= MAX_TICKS)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
package mineplex.core.particleeffects;
|
||||
|
||||
public class NewYearFireworkEffect //extends Effect
|
||||
{
|
||||
|
||||
/*private static final int MAX_TICKS = 1200;
|
||||
|
||||
private List<Location> _locations = new ArrayList<>();
|
||||
private List<Location> _fixedLocations = new ArrayList<>();
|
||||
private int _ticks = 0;
|
||||
|
||||
public NewYearFireworkEffect(JavaPlugin plugin, List<int[]> locations, List<int[]> fixedLocations, World world)
|
||||
{
|
||||
super(-1, null, plugin, 5);
|
||||
for (int[] locCoords : locations)
|
||||
{
|
||||
_locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2]));
|
||||
}
|
||||
for (int[] locCoords : fixedLocations)
|
||||
{
|
||||
_locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2]));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEffect()
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
int r = UtilMath.random.nextInt(_locations.size() - 1);
|
||||
Location location = _locations.get(r);
|
||||
UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2),
|
||||
new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1);
|
||||
}
|
||||
for (Location location : _fixedLocations)
|
||||
{
|
||||
UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2),
|
||||
new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1);
|
||||
}
|
||||
_ticks += 5;
|
||||
if (_ticks >= MAX_TICKS)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -1,87 +1,87 @@
|
||||
package mineplex.core.particleeffects;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.particles.ColoredParticle;
|
||||
import mineplex.core.common.util.particles.DustSpellColor;
|
||||
|
||||
public class TextEffect extends Effect
|
||||
{
|
||||
|
||||
private static final double IMAGE_SIZE = 0.2;
|
||||
|
||||
private String _text;
|
||||
private Font _font;
|
||||
private boolean _realtime;
|
||||
private boolean _invert;
|
||||
private BufferedImage _bufferedImage;
|
||||
|
||||
private ColoredParticle _coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.GREEN), null);
|
||||
|
||||
public TextEffect(JavaPlugin plugin, int ticks, String text, Location location, boolean realtime, boolean invert) throws Exception
|
||||
{
|
||||
super(ticks, new EffectLocation(location), plugin);
|
||||
_text = text;
|
||||
_font = new Font("Tahoma", Font.PLAIN, 16);
|
||||
_realtime = realtime;
|
||||
_invert = invert;
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
if (!_realtime)
|
||||
return;
|
||||
|
||||
_text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEffect()
|
||||
{
|
||||
if (_text == null || _font == null)
|
||||
{
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
if (_bufferedImage == null || _realtime)
|
||||
{
|
||||
_bufferedImage = UtilText.stringToBufferedImage(_font, _text);
|
||||
}
|
||||
int color = 0;
|
||||
for (int y = 0; y < _bufferedImage.getHeight(); y++)
|
||||
{
|
||||
for (int x = 0; x < _bufferedImage.getWidth(); x++)
|
||||
{
|
||||
color = _bufferedImage.getRGB(x, y);
|
||||
if (!_invert && java.awt.Color.black.getRGB() != color)
|
||||
continue;
|
||||
else if (_invert && java.awt.Color.black.getRGB() == color)
|
||||
continue;
|
||||
|
||||
Vector vector = new Vector((float) _bufferedImage.getWidth() / 2 - x, (float) _bufferedImage.getHeight() / 2 - y, 0).multiply(IMAGE_SIZE);
|
||||
vector = rotateAroundAxisY(vector, -_effectLocation.getFixedLocation().getYaw() * (Math.PI / 180));
|
||||
_coloredParticle.setLocation(_effectLocation.getFixedLocation().clone().add(vector));
|
||||
_coloredParticle.display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector rotateAroundAxisY(Vector v, double angle)
|
||||
{
|
||||
double x, z, cos, sin;
|
||||
cos = Math.cos(angle);
|
||||
sin = Math.sin(angle);
|
||||
x = v.getX() * cos + v.getZ() * sin;
|
||||
z = v.getX() * -sin + v.getZ() * cos;
|
||||
return v.setX(x).setZ(z);
|
||||
}
|
||||
|
||||
}
|
||||
package mineplex.core.particleeffects;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.particles.ColoredParticle;
|
||||
import mineplex.core.common.util.particles.DustSpellColor;
|
||||
|
||||
public class TextEffect extends Effect
|
||||
{
|
||||
|
||||
private static final double IMAGE_SIZE = 0.2;
|
||||
|
||||
private String _text;
|
||||
private Font _font;
|
||||
private boolean _realtime;
|
||||
private boolean _invert;
|
||||
private BufferedImage _bufferedImage;
|
||||
|
||||
private ColoredParticle _coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.GREEN), null);
|
||||
|
||||
public TextEffect(JavaPlugin plugin, int ticks, String text, Location location, boolean realtime, boolean invert) throws Exception
|
||||
{
|
||||
super(ticks, new EffectLocation(location), plugin);
|
||||
_text = text;
|
||||
_font = new Font("Tahoma", Font.PLAIN, 16);
|
||||
_realtime = realtime;
|
||||
_invert = invert;
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
if (!_realtime)
|
||||
return;
|
||||
|
||||
_text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEffect()
|
||||
{
|
||||
if (_text == null || _font == null)
|
||||
{
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
if (_bufferedImage == null || _realtime)
|
||||
{
|
||||
_bufferedImage = UtilText.stringToBufferedImage(_font, _text);
|
||||
}
|
||||
int color = 0;
|
||||
for (int y = 0; y < _bufferedImage.getHeight(); y++)
|
||||
{
|
||||
for (int x = 0; x < _bufferedImage.getWidth(); x++)
|
||||
{
|
||||
color = _bufferedImage.getRGB(x, y);
|
||||
if (!_invert && java.awt.Color.black.getRGB() != color)
|
||||
continue;
|
||||
else if (_invert && java.awt.Color.black.getRGB() == color)
|
||||
continue;
|
||||
|
||||
Vector vector = new Vector((float) _bufferedImage.getWidth() / 2 - x, (float) _bufferedImage.getHeight() / 2 - y, 0).multiply(IMAGE_SIZE);
|
||||
vector = rotateAroundAxisY(vector, -_effectLocation.getFixedLocation().getYaw() * (Math.PI / 180));
|
||||
_coloredParticle.setLocation(_effectLocation.getFixedLocation().clone().add(vector));
|
||||
_coloredParticle.display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector rotateAroundAxisY(Vector v, double angle)
|
||||
{
|
||||
double x, z, cos, sin;
|
||||
cos = Math.cos(angle);
|
||||
sin = Math.sin(angle);
|
||||
x = v.getX() * cos + v.getZ() * sin;
|
||||
z = v.getX() * -sin + v.getZ() * cos;
|
||||
return v.setX(x).setZ(z);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -166,7 +167,9 @@ public class Party
|
||||
*/
|
||||
public void sendMessage(String message)
|
||||
{
|
||||
_members.stream().map(Bukkit::getPlayer).forEach(player -> player.sendMessage(message));
|
||||
// Todo actually figure out why one of the members is no longer online
|
||||
// probably some desync between players and something
|
||||
_members.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).forEach(player -> player.sendMessage(message));
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
|
@ -51,7 +51,7 @@ public class PartyMethodManager
|
||||
Lang.NOT_OWNER.send(caller);
|
||||
return;
|
||||
}
|
||||
if(_plugin.getInviteManager().isInvitedTo(possible.getUniqueId(), party.getName()))
|
||||
if(possible != null && _plugin.getInviteManager().isInvitedTo(possible.getUniqueId(), party.getName()))
|
||||
{
|
||||
Lang.ALREADY_INVITED.send(caller, target);
|
||||
return;
|
||||
|
@ -867,4 +867,5 @@ public class ReportManager
|
||||
{
|
||||
return NAME + " #" + reportId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -5,7 +5,7 @@ import java.util.Iterator;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.hub.server;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.serverdata.data.MinecraftServer;
|
||||
|
||||
public class ServerInfo
|
||||
@ -22,19 +23,6 @@ public class ServerInfo
|
||||
|
||||
public boolean isDevServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
int index = Name.lastIndexOf('-');
|
||||
if (index != -1)
|
||||
{
|
||||
int id = Integer.parseInt(Name.substring(index + 1));
|
||||
return id >= 777;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return UtilServer.isDevServer(Name);
|
||||
}
|
||||
}
|
3
Plugins/Nautilus.Game.Arcade.UHC.WorldGen/plugin.yml
Normal file
3
Plugins/Nautilus.Game.Arcade.UHC.WorldGen/plugin.yml
Normal file
@ -0,0 +1,3 @@
|
||||
name: UHC-WorldGen
|
||||
main: nautilus.game.arcade.uhc.WorldGen
|
||||
version: 0.1
|
28
Plugins/Nautilus.Game.Arcade.UHC.WorldGen/pom.xml
Normal file
28
Plugins/Nautilus.Game.Arcade.UHC.WorldGen/pom.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>mineplex-plugin</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<relativePath>../plugin.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>UHC WorldGen</name>
|
||||
<artifactId>nautilus-game-arcade-uhc-worldgen</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.8.8-1.9-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.zeroturnaround</groupId>
|
||||
<artifactId>zt-zip</artifactId>
|
||||
<version>1.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,245 @@
|
||||
package nautilus.game.arcade.uhc;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.BiomeBase;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.spigotmc.WatchdogThread;
|
||||
import org.zeroturnaround.zip.ZipEntrySource;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
public class WorldGen extends JavaPlugin implements Runnable, Listener
|
||||
{
|
||||
private static final int MIN_X = -1000;
|
||||
private static final int MIN_Z = -1000;
|
||||
private static final int MAX_X = 1000;
|
||||
private static final int MAX_Z = 1000;
|
||||
private static final int VIEW_DISTANCE = 5;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
BiomeBase.getBiomes()[BiomeBase.OCEAN.id] = BiomeBase.PLAINS;
|
||||
BiomeBase.getBiomes()[BiomeBase.DEEP_OCEAN.id] = BiomeBase.PLAINS;
|
||||
BiomeBase.getBiomes()[BiomeBase.SWAMPLAND.id] = BiomeBase.PLAINS;
|
||||
BiomeBase.getBiomes()[BiomeBase.RIVER.id] = BiomeBase.PLAINS;
|
||||
|
||||
WatchdogThread.doStop();
|
||||
|
||||
getServer().getScheduler().runTaskTimer(this, this, 20L, 20L * 5L);
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(AsyncPlayerPreLoginEvent event)
|
||||
{
|
||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||
event.setKickMessage("Shoo, go away");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
File root = new File(".");
|
||||
|
||||
if (!root.exists())
|
||||
{
|
||||
getLogger().severe("Root folder does not exist. Aborting");
|
||||
getServer().shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
File outputDirectory = new File(root, "output");
|
||||
if (!outputDirectory.exists())
|
||||
{
|
||||
if (!outputDirectory.mkdir())
|
||||
{
|
||||
getLogger().severe("Could not create output folder. Aborting");
|
||||
getServer().shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
long seed = ThreadLocalRandom.current().nextLong();
|
||||
|
||||
File outputFile = new File(outputDirectory, "UHC_Map" + seed + ".zip");
|
||||
|
||||
if (outputFile.exists())
|
||||
{
|
||||
getLogger().info("Seed " + seed + " has already been generated. Skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!outputFile.createNewFile())
|
||||
{
|
||||
getLogger().severe("Could not create new output file. Aborting");
|
||||
getServer().shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
getLogger().log(Level.SEVERE, "Could not create new output file. Aborting", e);
|
||||
getServer().shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
getLogger().info("Generating world seed " + seed);
|
||||
|
||||
World world = new WorldCreator("generating")
|
||||
.environment(World.Environment.NORMAL)
|
||||
.seed(seed)
|
||||
.createWorld();
|
||||
world.setDifficulty(Difficulty.HARD);
|
||||
world.setKeepSpawnInMemory(false);
|
||||
|
||||
int minChunkX = (MIN_X >> 4) - VIEW_DISTANCE;
|
||||
int minChunkZ = (MIN_Z >> 4) - VIEW_DISTANCE;
|
||||
int maxChunkX = (MAX_X >> 4) + VIEW_DISTANCE;
|
||||
int maxChunkZ = (MAX_Z >> 4) + VIEW_DISTANCE;
|
||||
|
||||
for (int x = minChunkX; x <= maxChunkX; x++)
|
||||
{
|
||||
getLogger().info("Generating x coord " + x);
|
||||
for (int z = minChunkZ; z <= maxChunkZ; z++)
|
||||
{
|
||||
world.getChunkAt(x, z).load(true);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = minChunkX; x <= maxChunkX; x++)
|
||||
{
|
||||
getLogger().info("Unloading x coord " + x);
|
||||
for (int z = minChunkZ; z <= maxChunkZ; z++)
|
||||
{
|
||||
world.getChunkAt(x, z).unload(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
getLogger().info("Unloading and saving world");
|
||||
|
||||
Bukkit.unloadWorld(world, true);
|
||||
|
||||
getLogger().info("Finished unloading and saving world");
|
||||
|
||||
StringBuilder worldconfig = new StringBuilder();
|
||||
worldconfig.append("MAP_NAME:UHC World").append(System.lineSeparator());
|
||||
worldconfig.append("MAP_AUTHOR:Mineplex").append(System.lineSeparator());
|
||||
worldconfig.append("MIN_X:").append(MIN_X).append(System.lineSeparator());
|
||||
worldconfig.append("MIN_Z:").append(MIN_Z).append(System.lineSeparator());
|
||||
worldconfig.append("MAX_X:").append(MAX_X).append(System.lineSeparator());
|
||||
worldconfig.append("MAX_Z:").append(MAX_Z).append(System.lineSeparator());
|
||||
for (int i = 1; i <= 60; i++)
|
||||
{
|
||||
worldconfig.append("TEAM_NAME:").append(i).append(System.lineSeparator());
|
||||
worldconfig.append("TEAM_SPAWNS:0,0,0").append(System.lineSeparator());
|
||||
}
|
||||
|
||||
File worldFolder = new File(root, "generating");
|
||||
|
||||
File regionFolder = new File(worldFolder, "region");
|
||||
|
||||
File[] regionFiles = regionFolder.listFiles();
|
||||
|
||||
if (regionFiles == null)
|
||||
{
|
||||
getLogger().severe("Unexpected null region files. Aborting");
|
||||
getServer().shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
List<ZipEntrySource> zipEntrySourceList = new ArrayList<>();
|
||||
zipEntrySourceList.add(new ZipEntrySource()
|
||||
{
|
||||
@Override
|
||||
public String getPath()
|
||||
{
|
||||
return "WorldConfig.dat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZipEntry getEntry()
|
||||
{
|
||||
return new ZipEntry(getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException
|
||||
{
|
||||
return new ByteArrayInputStream(worldconfig.toString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
for (File file : regionFiles)
|
||||
{
|
||||
zipEntrySourceList.add(new ZipEntrySource()
|
||||
{
|
||||
@Override
|
||||
public String getPath()
|
||||
{
|
||||
return "region/" + file.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZipEntry getEntry()
|
||||
{
|
||||
return new ZipEntry(getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException
|
||||
{
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
zipEntrySourceList.add(new ZipEntrySource()
|
||||
{
|
||||
@Override
|
||||
public String getPath()
|
||||
{
|
||||
return "level.dat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZipEntry getEntry()
|
||||
{
|
||||
return new ZipEntry(getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException
|
||||
{
|
||||
return new FileInputStream(new File(worldFolder, "level.dat"));
|
||||
}
|
||||
});
|
||||
|
||||
ZipUtil.pack(zipEntrySourceList.toArray(new ZipEntrySource[zipEntrySourceList.size()]), outputFile);
|
||||
|
||||
FileUtils.deleteQuietly(worldFolder);
|
||||
|
||||
getLogger().info("Finished generating world seed " + seed);
|
||||
}
|
||||
}
|
@ -201,12 +201,6 @@ public class Arcade extends JavaPlugin
|
||||
|
||||
MinecraftServer.getServer().getPropertyManager().setProperty("debug", false);
|
||||
SpigotConfig.debug = false;
|
||||
|
||||
// Remove nasty biomes from natural terrain generation, used for UHC
|
||||
BiomeBase.getBiomes()[BiomeBase.OCEAN.id] = BiomeBase.PLAINS;
|
||||
BiomeBase.getBiomes()[BiomeBase.DEEP_OCEAN.id] = BiomeBase.PLAINS;
|
||||
BiomeBase.getBiomes()[BiomeBase.SWAMPLAND.id] = BiomeBase.PLAINS;
|
||||
BiomeBase.getBiomes()[BiomeBase.RIVER.id] = BiomeBase.PLAINS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,7 +99,7 @@ import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
||||
import mineplex.core.valentines.ValentinesGiftManager;
|
||||
import mineplex.core.youtube.YoutubeManager;
|
||||
@ -120,7 +120,6 @@ import mineplex.serverdata.Region;
|
||||
|
||||
import nautilus.game.arcade.addons.SoupAddon;
|
||||
import nautilus.game.arcade.addons.TeamArmorAddon;
|
||||
import nautilus.game.arcade.addons.compass.CompassAddon;
|
||||
import nautilus.game.arcade.booster.GameBoosterManager;
|
||||
import nautilus.game.arcade.command.CancelNextGameCommand;
|
||||
import nautilus.game.arcade.command.GameCmdModeCommand;
|
||||
@ -138,7 +137,6 @@ import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.games.event.EventModule;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.managers.GameAchievementManager;
|
||||
import nautilus.game.arcade.managers.GameCreationManager;
|
||||
import nautilus.game.arcade.managers.GameFlagManager;
|
||||
@ -188,9 +186,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private ArcadeShop _arcadeShop;
|
||||
|
||||
//Champions Modules
|
||||
private boolean _enabled = true;
|
||||
private Boolean _registered = null;
|
||||
private ClassManager _classManager;
|
||||
private boolean _enabled = true;
|
||||
private ClassManager _classManager;
|
||||
private SkillFactory _skillFactory;
|
||||
private ItemFactory _itemFactory;
|
||||
private Energy _energy;
|
||||
@ -253,8 +251,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
//Game commands
|
||||
public static final String GAME_CMD_MODE_FILE = "GAME_CMD_MODE.dat";
|
||||
private boolean _gameCommandMode;
|
||||
|
||||
private Rank _gameCommandRank;
|
||||
|
||||
public final boolean IsHolidayEnabled;
|
||||
|
||||
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
|
||||
@ -356,7 +354,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
new GameBoosterManager(plugin, boosterManager, hologramManager, npcManager, serverConfig.BoosterGroup);
|
||||
|
||||
// Game Addons
|
||||
new CompassAddon(plugin, this);
|
||||
new SoupAddon(plugin, this);
|
||||
new TeamArmorAddon(plugin, this);
|
||||
|
||||
@ -392,7 +389,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
loadRequiredRank();
|
||||
|
||||
_gameCommandMode = checkGameCommandMode();
|
||||
_gameCommandRank = checkGameCommandMode() ? Rank.ALL : Rank.JNR_DEV;
|
||||
|
||||
Region region = new File("eu.dat").exists() ? Region.EU : Region.US;
|
||||
|
||||
@ -494,23 +491,20 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
@Override
|
||||
public void draw(MineplexScoreboard scoreboard)
|
||||
{
|
||||
if (GetGame() != null && GetGame().GetCountdown() >= 0)
|
||||
if (GetGame() != null)
|
||||
{
|
||||
if (GetGame().GetCountdown() > 0)
|
||||
scoreboard.setSidebarName(C.Bold + "§lStarting in " + C.cGreen + "§l" + GetGame().GetCountdown() + (GetGame().GetCountdown() == 1 ? " Second" : " Seconds"));
|
||||
else if (GetGame().GetCountdown() == 0)
|
||||
scoreboard.setSidebarName(ChatColor.WHITE + "§lIn Progress...");
|
||||
else if (GetGame().GetState() == GameState.Recruit)
|
||||
scoreboard.setSidebarName(ChatColor.GREEN + "§l" + "Waiting for players");
|
||||
else if (GetGame().GetState() == GameState.Loading)
|
||||
scoreboard.setSidebarName(ChatColor.GREEN + "§l" + "Loading...");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetGame() instanceof UHC && !((UHC) GetGame()).isMapLoaded())
|
||||
{
|
||||
scoreboard.setSidebarName(((UHC) GetGame()).getObjectiveName(_gameLobbyManager.getColorTick()));
|
||||
}
|
||||
else
|
||||
{
|
||||
scoreboard.setSidebarName(ChatColor.GREEN + "§l" + "Waiting for Players");
|
||||
}
|
||||
scoreboard.setSidebarName(ChatColor.GREEN + "§l" + "Waiting for game");
|
||||
}
|
||||
|
||||
scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write( _gameManager.getValidPlayersForGameStart().size() + "/" + GetPlayerFull());
|
||||
@ -931,11 +925,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
// {
|
||||
// event.setMotd(ChatColor.GREEN + "Recruiting" + extrainformation);
|
||||
// }
|
||||
//UHC Timed
|
||||
if (_game != null && (_game.GetType() == GameType.UHC || _game.getClass().getSuperclass().equals(UHC.class)))
|
||||
{
|
||||
event.setMotd(((UHC) _game).getMotdStatus() + extrainformation);
|
||||
}
|
||||
|
||||
//Recruiting
|
||||
else if (_game == null || _game.GetState() == GameState.Recruit)
|
||||
{
|
||||
@ -1156,9 +1146,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
public void AdminOP(PlayerJoinEvent event)
|
||||
{
|
||||
// Give developers operator on their servers
|
||||
boolean testServer = _plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing");
|
||||
Rank minimum = Rank.OWNER;
|
||||
if (testServer)
|
||||
if (UtilServer.isTestServer() || UtilServer.isDevServer())
|
||||
{
|
||||
minimum = Rank.JNR_DEV;
|
||||
}
|
||||
@ -1752,7 +1741,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
if (_enabled)
|
||||
{
|
||||
enableChampionsModules();
|
||||
//enableChampionsModules();
|
||||
disableChampionsModules();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1884,23 +1874,25 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
return new File(GAME_CMD_MODE_FILE).exists();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Whether this server is in game command mode.
|
||||
* Returns the minimum rank requirement to use game commands.
|
||||
*
|
||||
* @return The minimum rank requirement.
|
||||
*/
|
||||
public boolean isGameCommandMode()
|
||||
public Rank getGameCommandRank()
|
||||
{
|
||||
return _gameCommandMode;
|
||||
return _gameCommandRank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this server's game command mode state.
|
||||
* Sets this server's minimum rank requirement to use game commands.
|
||||
*
|
||||
* @param state Whether to enable or disable game commands.
|
||||
* @param rank The minimum rank requirement.
|
||||
*/
|
||||
public void setGameCommandMode(boolean state)
|
||||
public void setGameCommandMode(Rank rank)
|
||||
{
|
||||
_gameCommandMode = state;
|
||||
_gameCommandRank = rank;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1912,17 +1904,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
* @return Whether or not the player can successfully use the command.
|
||||
*/
|
||||
public boolean canPlayerUseGameCmd(Player player)
|
||||
{
|
||||
if (_gameCommandMode)
|
||||
{
|
||||
// When enabled, anyone can use game commands.
|
||||
return true;
|
||||
}
|
||||
|
||||
{
|
||||
// Check whether they are of high enough rank status.
|
||||
if (!GetClients().hasRank(player, Rank.JNR_DEV))
|
||||
if (_gameCommandRank == null || !GetClients().hasRank(player, _gameCommandRank))
|
||||
{
|
||||
player.sendMessage(F.main("Server", "You are not allowed to use game commands."));
|
||||
player.sendMessage(F.main("Game", "You are not allowed to use game commands."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -110,10 +110,12 @@ import nautilus.game.arcade.game.games.survivalgames.modes.UHCSurvivalgames;
|
||||
import nautilus.game.arcade.game.games.tug.Tug;
|
||||
import nautilus.game.arcade.game.games.turfforts.TurfForts;
|
||||
import nautilus.game.arcade.game.games.typewars.TypeWars;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.game.games.uhc.UHCSolo;
|
||||
import nautilus.game.arcade.game.games.uhc.UHCSoloSpeed;
|
||||
import nautilus.game.arcade.game.games.uhc.UHCTeams;
|
||||
import nautilus.game.arcade.game.games.uhc.UHCTeamsSpeed;
|
||||
import nautilus.game.arcade.game.games.uhc.modes.Assassins;
|
||||
import nautilus.game.arcade.game.games.uhc.modes.BloodDiamonds;
|
||||
import nautilus.game.arcade.game.games.uhc.modes.CutClean;
|
||||
import nautilus.game.arcade.game.games.uhc.modes.GodBattles;
|
||||
import nautilus.game.arcade.game.games.valentines.Valentines;
|
||||
import nautilus.game.arcade.game.games.wither.WitherGame;
|
||||
@ -192,7 +194,10 @@ public enum GameType
|
||||
SurvivalGamesTeams(TeamSurvivalGames.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false),
|
||||
Tug(Tug.class, GameDisplay.Tug),
|
||||
TurfWars(TurfForts.class, GameDisplay.TurfWars),
|
||||
UHC(UHC.class, GameDisplay.UHC),
|
||||
UHC(UHCTeams.class, GameDisplay.UHC),
|
||||
UHCSolo(UHCSolo.class, GameDisplay.UHCSolo, new GameType[] { GameType.UHC }, false),
|
||||
UHCSoloSpeed(UHCSoloSpeed.class, GameDisplay.UHCSoloSpeed, new GameType[] { GameType.UHC }, false),
|
||||
UHCTeamsSpeed(UHCTeamsSpeed.class, GameDisplay.UHCTeamsSpeed, new GameType[] { GameType.UHC }, false),
|
||||
WitherAssault(WitherGame.class, GameDisplay.WitherAssault),
|
||||
Wizards(Wizards.class, GameDisplay.Wizards, new Pair[]
|
||||
{
|
||||
@ -242,7 +247,6 @@ public enum GameType
|
||||
new GameMode(Elementalist.class, GameType.Skywars, "Elementalist"),
|
||||
new GameMode(TeamBuild.class, GameType.Build, "Team Master Builders"),
|
||||
new GameMode(DukesOfDecoration.class, GameType.Build, "Dukes Of Decoration"),
|
||||
new GameMode(CutClean.class, GameType.UHC, "Cut Clean"),
|
||||
new GameMode(GodBattles.class, GameType.UHC, "God Battles"),
|
||||
new GameMode(BloodDiamonds.class, GameType.UHC, "Blood Diamonds"),
|
||||
new GameMode(Assassins.class, GameType.UHC, "Assassins"),
|
||||
|
@ -1,257 +0,0 @@
|
||||
package nautilus.game.arcade.addons.compass;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.gui.spectatorMenu.SpectatorShop;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CompassAddon extends MiniPlugin
|
||||
{
|
||||
public ArcadeManager Manager;
|
||||
|
||||
private SpectatorShop _spectatorShop;
|
||||
|
||||
public CompassAddon(JavaPlugin plugin, ArcadeManager manager)
|
||||
{
|
||||
super("Compass Addon", plugin);
|
||||
|
||||
Manager = manager;
|
||||
|
||||
_spectatorShop = new SpectatorShop(this, manager, manager.GetClients(), manager.GetDonation());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
if (Manager.GetGame() == null)
|
||||
return;
|
||||
|
||||
if (!Manager.GetGame().IsLive())
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (!Manager.GetGame().CompassEnabled && Manager.GetGame().IsAlive(player))
|
||||
continue;
|
||||
|
||||
GameTeam team = Manager.GetGame().GetTeam(player);
|
||||
|
||||
Player target = null;
|
||||
GameTeam targetTeam = null;
|
||||
double bestDist = 0;
|
||||
|
||||
for (Player other : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if (other.equals(player))
|
||||
continue;
|
||||
|
||||
GameTeam otherTeam = Manager.GetGame().GetTeam(other);
|
||||
|
||||
//Same Team (Not Solo Game) && Alive
|
||||
if (Manager.GetGame().GetTeamList().size() > 1 && (team != null && team.equals(otherTeam)) && Manager.GetGame().IsAlive(player))
|
||||
continue;
|
||||
|
||||
double dist = UtilMath.offset(player, other);
|
||||
|
||||
if (target == null || dist < bestDist)
|
||||
{
|
||||
CompassAttemptTargetEvent tE = new CompassAttemptTargetEvent(player, other);
|
||||
Bukkit.getServer().getPluginManager().callEvent(tE);
|
||||
|
||||
if (tE.isCancelled())
|
||||
continue;
|
||||
|
||||
target = other;
|
||||
targetTeam = otherTeam;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
if (Manager.GetGame().CompassGiveItem || (Manager.GetGame().CompassGiveItemSpectators && Manager.isSpectator(player)))
|
||||
if (!player.getInventory().contains(Material.COMPASS))
|
||||
{
|
||||
if (player.getOpenInventory() == null || player.getOpenInventory().getCursor() == null || player.getOpenInventory().getCursor().getType() != Material.COMPASS)
|
||||
{
|
||||
ItemStack stack = new ItemStack(Material.COMPASS);
|
||||
|
||||
ItemMeta itemMeta = stack.getItemMeta();
|
||||
itemMeta.setDisplayName(C.cGreen + C.Bold + "Tracking Compass");
|
||||
stack.setItemMeta(itemMeta);
|
||||
|
||||
player.getInventory().addItem(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.setCompassTarget(target.getLocation());
|
||||
|
||||
double heightDiff = target.getLocation().getY() - player.getLocation().getY();
|
||||
|
||||
//Action Bar
|
||||
if (UtilGear.isMat(player.getItemInHand(), Material.COMPASS))
|
||||
{
|
||||
UtilTextBottom.display(
|
||||
" " + C.cWhite + C.Bold + "Nearest Player: " + targetTeam.GetColor() + target.getName() +
|
||||
" " + C.cWhite + C.Bold + "Distance: " + targetTeam.GetColor() + UtilMath.trim(1, bestDist) +
|
||||
" " + C.cWhite + C.Bold + "Height: " + targetTeam.GetColor() + UtilMath.trim(1, heightDiff), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void DropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (Manager.GetGame() == null || !Manager.GetGame().CompassEnabled)
|
||||
return;
|
||||
|
||||
if (!UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.COMPASS, (byte)0))
|
||||
return;
|
||||
|
||||
//Cancel
|
||||
event.setCancelled(true);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot drop " + F.item("Target Compass") + "."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void DeathRemove(PlayerDeathEvent event)
|
||||
{
|
||||
if (Manager.GetGame() == null || !Manager.GetGame().CompassEnabled)
|
||||
return;
|
||||
|
||||
HashSet<org.bukkit.inventory.ItemStack> remove = new HashSet<org.bukkit.inventory.ItemStack>();
|
||||
|
||||
for (org.bukkit.inventory.ItemStack item : event.getDrops())
|
||||
if (UtilInv.IsItem(item, Material.COMPASS, (byte)0))
|
||||
remove.add(item);
|
||||
|
||||
for (org.bukkit.inventory.ItemStack item : remove)
|
||||
event.getDrops().remove(item);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void SpectatorTeleport(PlayerInteractEvent event)
|
||||
{
|
||||
if (Manager.GetGame() == null)
|
||||
return;
|
||||
|
||||
if (event.getAction() == Action.PHYSICAL)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UtilGear.isMat(player.getItemInHand(), Material.COMPASS))
|
||||
return;
|
||||
|
||||
if (Manager.GetGame().IsAlive(player))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
// Teleport to nearest player when you left click compass
|
||||
|
||||
if (!Recharge.Instance.use(player, "Spectate", 3000, true, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spectateNearestPlayer(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Right click - open spectator menu
|
||||
|
||||
_spectatorShop.attemptShopOpen(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void spectateNearestPlayer(Player spectator)
|
||||
{
|
||||
GameTeam team = Manager.GetGame().GetTeam(spectator);
|
||||
|
||||
Player target = null;
|
||||
double bestDist = 0;
|
||||
|
||||
for (Player other : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
GameTeam otherTeam = Manager.GetGame().GetTeam(other);
|
||||
|
||||
//Same Team (Not Solo Game) && Alive
|
||||
if (Manager.GetGame().GetTeamList().size() > 1 && (team != null && team.equals(otherTeam)) && Manager.GetGame().IsAlive(spectator))
|
||||
continue;
|
||||
|
||||
double dist = UtilMath.offset(spectator, other);
|
||||
|
||||
if (target == null || dist < bestDist)
|
||||
{
|
||||
target = other;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
spectator.teleport(target.getLocation().add(0, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void closeShop(GameStateChangeEvent event)
|
||||
{
|
||||
// Close shop when a game ends
|
||||
if (event.GetState().equals(Game.GameState.End))
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (_spectatorShop.isPlayerInShop(player))
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateShop(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
_spectatorShop.update();
|
||||
}
|
||||
|
||||
}
|
@ -9,6 +9,8 @@ import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
|
||||
import io.netty.util.internal.chmv8.ForkJoinPool.ManagedBlocker;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
|
||||
/**
|
||||
@ -18,29 +20,34 @@ public class GameCmdModeCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
public GameCmdModeCommand(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, Rank.JNR_DEV, "gamecmdmode");
|
||||
super(plugin, Rank.JNR_DEV, "gamecmdrank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
File file = new File(ArcadeManager.GAME_CMD_MODE_FILE);
|
||||
|
||||
if (Plugin.isGameCommandMode())
|
||||
if (args.length < 1)
|
||||
{
|
||||
// Disable game command mode.
|
||||
if (file.exists())
|
||||
{
|
||||
file.delete();
|
||||
}
|
||||
|
||||
Plugin.setGameCommandMode(false);
|
||||
caller.sendMessage(F.main("Server", "Game commands are now " + C.cRed + "disabled" +
|
||||
C.cGray + "."));
|
||||
caller.sendMessage(F.main("Game", "/gamecmdrank <rank>"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
File file = new File(ArcadeManager.GAME_CMD_MODE_FILE);
|
||||
Rank rank = Plugin.getGameCommandRank();
|
||||
Rank newRank = null;
|
||||
|
||||
try
|
||||
{
|
||||
newRank = Rank.valueOf(args[0]);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
caller.sendMessage(F.main("Game", C.cRedB + "Invalid rank!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newRank == Rank.ALL)
|
||||
{
|
||||
// Enable game command mode.
|
||||
if (!file.exists())
|
||||
{
|
||||
try
|
||||
@ -52,10 +59,16 @@ public class GameCmdModeCommand extends CommandBase<ArcadeManager>
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Plugin.setGameCommandMode(true);
|
||||
caller.sendMessage(F.main("Server", "Game commands are now " + C.cGreen + "enabled" +
|
||||
C.cGray + "."));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (file.exists())
|
||||
{
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
Plugin.setGameCommandMode(newRank);
|
||||
caller.sendMessage(F.main("Game", "Players now need at least rank " + newRank.getTag(true, true) + C.cGray + " to use game commands."));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package nautilus.game.arcade.game;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class DebugCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
public DebugCommand(String commandName, Rank requiredRank, Rank... specificRanks)
|
||||
{
|
||||
super(Managers.get(ArcadeManager.class), requiredRank, specificRanks, commandName);
|
||||
}
|
||||
|
||||
public abstract void Execute(Player caller, String[] args);
|
||||
}
|
@ -48,6 +48,8 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
@ -72,6 +74,7 @@ import mineplex.core.utils.UtilGameProfile;
|
||||
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeFormat;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
@ -79,12 +82,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.games.hideseek.HideSeek;
|
||||
import nautilus.game.arcade.game.games.minestrike.Minestrike;
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.SneakyAssassins;
|
||||
import nautilus.game.arcade.game.games.survivalgames.SurvivalGames;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.game.games.wither.WitherGame;
|
||||
import nautilus.game.arcade.game.modules.Module;
|
||||
import nautilus.game.arcade.kit.ChampionsKit;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
@ -281,10 +278,6 @@ public abstract class Game implements Listener
|
||||
public boolean DontAllowOverfill = false;
|
||||
|
||||
// Addons
|
||||
public boolean CompassEnabled = false;
|
||||
public boolean CompassGiveItem = true;
|
||||
public boolean CompassGiveItemSpectators = true;
|
||||
|
||||
public boolean SoupEnabled = true;
|
||||
public boolean TeamArmor = false;
|
||||
public boolean TeamArmorHotbar = false;
|
||||
@ -299,7 +292,7 @@ public abstract class Game implements Listener
|
||||
public double XpMult = 1;
|
||||
|
||||
public boolean SpeedMeasurement = false;
|
||||
|
||||
|
||||
// Chat Stats
|
||||
public final ChatStatData Kills = new ChatStatData("Kills", "Kills", true);
|
||||
public final ChatStatData Assists = new ChatStatData("Assists", "Assists", true);
|
||||
@ -365,6 +358,8 @@ public abstract class Game implements Listener
|
||||
|
||||
// Used for "%player% is your teammate"
|
||||
public boolean ShowTeammateMessage = false;
|
||||
|
||||
public boolean ShowEveryoneSpecChat = true;
|
||||
|
||||
public boolean ForceTeamSize = true;
|
||||
public int PlayersPerTeam = 2;
|
||||
@ -383,7 +378,8 @@ public abstract class Game implements Listener
|
||||
private Map<Class<? extends Module>, Module> _modules = new HashMap<>();
|
||||
|
||||
private HashMap<UUID, LinkedList<Triple<Double, Double, Double>>> _playerPastLocs = new HashMap<>();
|
||||
|
||||
private Set<DebugCommand> _debugCommands = new HashSet<>();
|
||||
|
||||
public Game(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
|
||||
{
|
||||
Manager = manager;
|
||||
@ -470,14 +466,14 @@ public abstract class Game implements Listener
|
||||
System.out.println("Loading " + GetName() + "...");
|
||||
}
|
||||
|
||||
public <T extends Module> T registerModule(T module)
|
||||
// You should never use this so please don't. Use Module.register instead
|
||||
public final void registerModule(Module module)
|
||||
{
|
||||
if (!_modules.containsKey(module.getClass()))
|
||||
{
|
||||
_modules.put(module.getClass(), module);
|
||||
UtilServer.RegisterEvents(module);
|
||||
module.initialize(this);
|
||||
return module;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -495,6 +491,23 @@ public abstract class Game implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
public void registerDebugCommand(DebugCommand debugCommand)
|
||||
{
|
||||
if (UtilServer.isTestServer())
|
||||
{
|
||||
debugCommand.setRequiredRank(Rank.SNR_MODERATOR);
|
||||
}
|
||||
_debugCommands.add(debugCommand);
|
||||
for (String string : debugCommand.Aliases())
|
||||
{
|
||||
if (CommandCenter.getCommands().containsKey(string.toLowerCase()))
|
||||
{
|
||||
throw new IllegalArgumentException("Existing command: " + string.toLowerCase());
|
||||
}
|
||||
}
|
||||
CommandCenter.Instance.addCommand(debugCommand);
|
||||
}
|
||||
|
||||
public void setKits(Kit[] kits)
|
||||
{
|
||||
_kits = kits;
|
||||
@ -658,6 +671,68 @@ public abstract class Game implements Listener
|
||||
return _gameState;
|
||||
}
|
||||
|
||||
public void prepareToRecruit()
|
||||
{
|
||||
generateTeams();
|
||||
recruit();
|
||||
}
|
||||
|
||||
public void recruit()
|
||||
{
|
||||
SetState(GameState.Recruit);
|
||||
}
|
||||
|
||||
|
||||
public void generateTeams()
|
||||
{
|
||||
int count = 1;
|
||||
|
||||
for (String team : WorldData.SpawnLocs.keySet())
|
||||
{
|
||||
ChatColor color;
|
||||
|
||||
if (team.equalsIgnoreCase("RED")) color = ChatColor.RED;
|
||||
else if (team.equalsIgnoreCase("YELLOW")) color = ChatColor.YELLOW;
|
||||
else if (team.equalsIgnoreCase("GREEN")) color = ChatColor.GREEN;
|
||||
else if (team.equalsIgnoreCase("BLUE")) color = ChatColor.AQUA;
|
||||
else
|
||||
{
|
||||
color = ChatColor.DARK_GREEN;
|
||||
|
||||
if (GetTeamList().size()%14 == 0) if (WorldData.SpawnLocs.size() > 1) color = ChatColor.RED;
|
||||
if (GetTeamList().size()%14 == 1) color = ChatColor.YELLOW;
|
||||
if (GetTeamList().size()%14 == 2) color = ChatColor.GREEN;
|
||||
if (GetTeamList().size()%14 == 3) color = ChatColor.AQUA;
|
||||
if (GetTeamList().size()%14 == 4) color = ChatColor.GOLD;
|
||||
if (GetTeamList().size()%14 == 5) color = ChatColor.LIGHT_PURPLE;
|
||||
if (GetTeamList().size()%14 == 6) color = ChatColor.DARK_BLUE;
|
||||
if (GetTeamList().size()%14 == 7) color = ChatColor.WHITE;
|
||||
if (GetTeamList().size()%14 == 8) color = ChatColor.BLUE;
|
||||
if (GetTeamList().size()%14 == 9) color = ChatColor.DARK_GREEN;
|
||||
if (GetTeamList().size()%14 == 10) color = ChatColor.DARK_PURPLE;
|
||||
if (GetTeamList().size()%14 == 11) color = ChatColor.DARK_RED;
|
||||
if (GetTeamList().size()%14 == 12) color = ChatColor.DARK_AQUA;
|
||||
}
|
||||
|
||||
//Random Names
|
||||
String teamName = team;
|
||||
if (WorldData.SpawnLocs.size() > 12)
|
||||
{
|
||||
teamName = String.valueOf(count);
|
||||
count++;
|
||||
}
|
||||
|
||||
GameTeam newTeam = new GameTeam(this, teamName, color, WorldData.SpawnLocs.get(team));
|
||||
AddTeam(newTeam);
|
||||
}
|
||||
|
||||
//Restrict Kits
|
||||
RestrictKits();
|
||||
|
||||
//Parse Data
|
||||
ParseData();
|
||||
}
|
||||
|
||||
public void SetState(GameState state)
|
||||
{
|
||||
_gameState = state;
|
||||
@ -666,29 +741,10 @@ public abstract class Game implements Listener
|
||||
if (this._gameState == Game.GameState.Prepare)
|
||||
{
|
||||
Managers.get(AntiHack.class).enableNewAnticheat();
|
||||
if (this instanceof HideSeek)
|
||||
{
|
||||
Managers.get(AntiHack.class).registerFilter(player ->
|
||||
{
|
||||
if (GetTeam(player) == ((HideSeek) this).getHiders())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
else if (this instanceof SurvivalGames || this instanceof Minestrike || this instanceof SneakyAssassins || this instanceof UHC || this instanceof WitherGame)
|
||||
{
|
||||
Managers.get(AntiHack.class).registerFilter(player ->
|
||||
{
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (this._gameState == Game.GameState.End)
|
||||
{
|
||||
Managers.get(AntiHack.class).disableNewAnticheat();
|
||||
Managers.get(AntiHack.class).registerFilter(null);
|
||||
}
|
||||
|
||||
|
||||
@ -769,14 +825,15 @@ public abstract class Game implements Listener
|
||||
{
|
||||
ProgressingKit progressingKit = (ProgressingKit) kit;
|
||||
|
||||
if(!progressingKit.hasUpgrades())
|
||||
if (!progressingKit.hasUpgrades())
|
||||
{
|
||||
for(Perk perk : progressingKit.getNonUpgradePerks())
|
||||
for (Perk perk : progressingKit.getNonUpgradePerks())
|
||||
{
|
||||
UtilServer.RegisterEvents(perk);
|
||||
perk.registeredEvents();
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Perk[] upgradePerks : progressingKit.getPerks())
|
||||
{
|
||||
@ -862,6 +919,29 @@ public abstract class Game implements Listener
|
||||
// Use this to parse in extra location data from maps
|
||||
}
|
||||
|
||||
public boolean loadNecessaryChunks(long maxMilliseconds)
|
||||
{
|
||||
long endTime = System.currentTimeMillis() + maxMilliseconds;
|
||||
|
||||
int minX = WorldData.MinX >> 4;
|
||||
int minZ = WorldData.MinZ >> 4;
|
||||
int maxX = WorldData.MaxX >> 4;
|
||||
int maxZ = WorldData.MaxZ >> 4;
|
||||
|
||||
for (int x = minX; x <= maxX; x++)
|
||||
{
|
||||
for (int z = minZ; z <= maxZ; z++)
|
||||
{
|
||||
if (System.currentTimeMillis() >= endTime)
|
||||
return false;
|
||||
|
||||
WorldData.World.getChunkAt(x, z);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetPlayerTeam(Player player, GameTeam team, boolean in)
|
||||
{
|
||||
// Clean Old Team
|
||||
@ -2354,8 +2434,15 @@ public abstract class Game implements Listener
|
||||
this._modules.clear();
|
||||
}
|
||||
|
||||
public void cleanupCommands()
|
||||
{
|
||||
this._debugCommands.forEach(command -> CommandCenter.Instance.removeCommand(command));
|
||||
this._debugCommands.clear();
|
||||
}
|
||||
|
||||
public <T extends Module> T getModule(Class<T> clazz)
|
||||
{
|
||||
return clazz.cast(_modules.get(clazz));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.modules.RejoinModule;
|
||||
import nautilus.game.arcade.game.modules.RejoinModule.RejoinPlayerData;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -25,15 +27,8 @@ import java.util.List;
|
||||
|
||||
public abstract class TeamGame extends Game
|
||||
{
|
||||
public long RejoinTime = 120000;
|
||||
|
||||
protected ArrayList<GameTeam> _places = new ArrayList<GameTeam>();
|
||||
|
||||
public NautHashMap<String, Long> RejoinTimes = new NautHashMap<String, Long>();
|
||||
public NautHashMap<String, GameTeam> RejoinTeam = new NautHashMap<String, GameTeam>();
|
||||
public NautHashMap<String, Kit> RejoinKit = new NautHashMap<String, Kit>();
|
||||
public NautHashMap<String, Double> RejoinHealth = new NautHashMap<String, Double>();
|
||||
|
||||
public TeamGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
|
||||
{
|
||||
super(manager, gameType, kits, gameDesc);
|
||||
@ -74,137 +69,6 @@ public abstract class TeamGame extends Game
|
||||
return;
|
||||
|
||||
team.RemovePlayer(player);
|
||||
|
||||
if (player.isDead())
|
||||
return;
|
||||
|
||||
if (player.getWorld().getName().equalsIgnoreCase("world"))
|
||||
return;
|
||||
|
||||
if (!QuitOut)
|
||||
{
|
||||
//Store
|
||||
RejoinTimes.put(player.getName(), System.currentTimeMillis());
|
||||
RejoinTeam.put(player.getName(), team);
|
||||
|
||||
if (GetKit(player) != null)
|
||||
RejoinKit.put(player.getName(), GetKit(player));
|
||||
|
||||
RejoinHealth.put(player.getName(), player.getHealth());
|
||||
|
||||
if (!GetLocationStore().containsKey(player.getName()))
|
||||
{
|
||||
GetLocationStore().put(player.getName(), player.getLocation());
|
||||
}
|
||||
|
||||
//Announcement
|
||||
Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! " + UtilTime.convert(RejoinTime, 0, TimeUnit.MINUTES) + " minutes to rejoin.", false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void PlayerLoginAllow(PlayerLoginEvent event)
|
||||
{
|
||||
if (!InProgress() || QuitOut)
|
||||
return;
|
||||
|
||||
//Rejoined
|
||||
GameTeam team = RejoinTeam.remove(event.getPlayer().getName());
|
||||
if (team != null && RejoinTimes.remove(event.getPlayer().getName()) != null)
|
||||
{
|
||||
team.AddPlayer(event.getPlayer(), true);
|
||||
Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!", false);
|
||||
|
||||
|
||||
Kit kit = RejoinKit.remove(event.getPlayer().getName());
|
||||
if (kit != null)
|
||||
_playerKit.put(event.getPlayer(), kit);
|
||||
|
||||
// final Player player = event.getPlayer();
|
||||
// Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
|
||||
// {
|
||||
// @Override
|
||||
// public void run()
|
||||
// {
|
||||
// if (RejoinHealth.containsKey(player.getName()))
|
||||
// {
|
||||
// double health = RejoinHealth.remove(player.getName());
|
||||
// player.setHealth(health);
|
||||
// player.sendMessage("DEBUG: restored hp to " + health);
|
||||
// }
|
||||
// }
|
||||
// }, 20);
|
||||
}
|
||||
}
|
||||
|
||||
//Do this on Join, not Login, otherwise player no get heal.
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void playerRejoinGame(PlayerJoinEvent event)
|
||||
{
|
||||
if (!InProgress() || QuitOut)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (RejoinHealth.containsKey(player.getName()))
|
||||
{
|
||||
double health = RejoinHealth.remove(player.getName());
|
||||
if (health > 0)
|
||||
{
|
||||
getArcadeManager().runSyncLater(() ->
|
||||
{
|
||||
player.setHealth(health);
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerRejoinExpire(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC || QuitOut)
|
||||
return;
|
||||
|
||||
Iterator<String> rejoinIterator = RejoinTimes.keySet().iterator();
|
||||
|
||||
while (rejoinIterator.hasNext())
|
||||
{
|
||||
String name = rejoinIterator.next();
|
||||
|
||||
if (!UtilTime.elapsed(RejoinTimes.get(name), RejoinTime))
|
||||
continue;
|
||||
|
||||
rejoinIterator.remove();
|
||||
|
||||
//Get Team (By Name)
|
||||
GameTeam team = RejoinTeam.remove(name);
|
||||
if (team != null)
|
||||
Announce(team.GetColor() + C.Bold + name + " did not reconnect in time!", false);
|
||||
|
||||
RejoinKit.remove(name);
|
||||
RejoinHealth.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void RejoinCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (!QuitOut && event.getPlayer().isOp() && event.getMessage().startsWith("/allowrejoin"))
|
||||
{
|
||||
String[] toks = event.getMessage().split(" ");
|
||||
|
||||
if (toks.length <= 1)
|
||||
{
|
||||
event.getPlayer().sendMessage("Missing Param!");
|
||||
}
|
||||
else
|
||||
{
|
||||
RejoinTimes.put(toks[1], System.currentTimeMillis());
|
||||
event.getPlayer().sendMessage("Allowed " + toks[1] + " to rejoin!");
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void EndCheck()
|
||||
@ -221,8 +85,13 @@ public abstract class TeamGame extends Game
|
||||
if (!QuitOut)
|
||||
{
|
||||
//Offline Player Team
|
||||
for (GameTeam team : RejoinTeam.values())
|
||||
teamsAlive.add(team);
|
||||
if (getModule(RejoinModule.class) != null)
|
||||
{
|
||||
for (RejoinPlayerData data : getModule(RejoinModule.class).getData())
|
||||
{
|
||||
teamsAlive.add(data.getTeam());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (teamsAlive.size() <= 1)
|
||||
|
@ -14,6 +14,7 @@ import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.barbarians.kits.*;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
import nautilus.game.arcade.stats.BlockBreakStatTracker;
|
||||
@ -40,7 +41,8 @@ public class Barbarians extends SoloGame
|
||||
});
|
||||
|
||||
this.DamageTeamSelf = true;
|
||||
this.CompassEnabled = true;
|
||||
|
||||
new CompassModule().register(this);
|
||||
|
||||
this.BlockBreakAllow.add(5);
|
||||
this.BlockBreakAllow.add(17);
|
||||
|
@ -18,6 +18,7 @@ import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.bridge.kits.*;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.ore.OreHider;
|
||||
import nautilus.game.arcade.ore.OreObsfucation;
|
||||
@ -205,7 +206,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
WorldWaterDamage = 0;
|
||||
WorldBoundaryKill = false;
|
||||
|
||||
CompassEnabled = true;
|
||||
new CompassModule().register(this);
|
||||
|
||||
DeathDropItems = true;
|
||||
|
||||
@ -1582,12 +1583,12 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
if (team.GetPlayers(true).size() > 0)
|
||||
teamsAlive.add(team);
|
||||
|
||||
if (!QuitOut)
|
||||
{
|
||||
//Offline Player Team
|
||||
for (GameTeam team : RejoinTeam.values())
|
||||
teamsAlive.add(team);
|
||||
}
|
||||
// if (!QuitOut)
|
||||
// {
|
||||
// //Offline Player Team
|
||||
// for (GameTeam team : RejoinTeam.values())
|
||||
// teamsAlive.add(team);
|
||||
// }
|
||||
|
||||
if (teamsAlive.size() <= 1)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ public class TeamBuild extends Build
|
||||
|
||||
TeamMode = true;
|
||||
|
||||
registerModule(new TeamModule());
|
||||
new TeamModule().register(this);
|
||||
|
||||
TeamPerSpawn = true;
|
||||
FillTeamsInOrderToCount = 2;
|
||||
|
@ -22,6 +22,7 @@ import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.common.dominate_data.CapturePointTDM;
|
||||
import nautilus.game.arcade.game.games.common.dominate_data.Resupply;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -63,8 +64,9 @@ public class TeamDeathmatch extends TeamGame
|
||||
|
||||
this.DeathOut = true;
|
||||
this.HungerSet = 20;
|
||||
this.WorldTimeSet = 2000;
|
||||
this.CompassEnabled = true;
|
||||
this.WorldTimeSet = 2000;
|
||||
|
||||
new CompassModule().register(this);
|
||||
|
||||
//this.EloRanking = true;
|
||||
//this.EloSetting.setEloSetting(2);
|
||||
|
@ -20,6 +20,7 @@ import nautilus.game.arcade.game.games.deathtag.kits.KitChaser;
|
||||
import nautilus.game.arcade.game.games.deathtag.kits.KitRunnerArcher;
|
||||
import nautilus.game.arcade.game.games.deathtag.kits.KitRunnerBasher;
|
||||
import nautilus.game.arcade.game.games.deathtag.kits.KitRunnerTraitor;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.NullKit;
|
||||
import nautilus.game.arcade.stats.ComeAtMeBroStatTracker;
|
||||
@ -73,7 +74,7 @@ public class DeathTag extends SoloGame
|
||||
this.DeathOut = false;
|
||||
this.HungerSet = 20;
|
||||
|
||||
this.CompassEnabled = true;
|
||||
new CompassModule().register(this);
|
||||
|
||||
this.PrepareFreeze = false;
|
||||
|
||||
|
@ -29,6 +29,7 @@ import nautilus.game.arcade.game.games.evolution.kits.KitEvolveSpeed;
|
||||
import nautilus.game.arcade.game.games.evolution.kits.KitHealth;
|
||||
import nautilus.game.arcade.game.games.evolution.mobs.*;
|
||||
import nautilus.game.arcade.game.games.evolution.trackers.*;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.ProgressingKit;
|
||||
import nautilus.game.arcade.stats.KillFastStatTracker;
|
||||
@ -117,8 +118,9 @@ public class Evolution extends SoloGame
|
||||
GemKillDeathRespawn = 2;
|
||||
GemAssistDeathRespawn = .5;
|
||||
|
||||
CompassEnabled = true;
|
||||
CompassGiveItem = false;
|
||||
new CompassModule()
|
||||
.setGiveCompass(false)
|
||||
.register(this);
|
||||
|
||||
AutomaticRespawn = false;
|
||||
DeathSpectateSecs = 4.0;
|
||||
|
@ -12,7 +12,7 @@ import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.addons.compass.CompassAttemptTargetEvent;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassAttemptTargetEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.EvoKit;
|
||||
import nautilus.game.arcade.game.games.evolution.Evolution;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent;
|
||||
@ -182,8 +182,11 @@ public class EvolveManager implements Listener
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
if (isEvolving(event.getTarget()))
|
||||
|
||||
if (!(event.getTarget() instanceof Player))
|
||||
return;
|
||||
|
||||
if (isEvolving((Player) event.getTarget()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ import nautilus.game.arcade.game.games.gravity.objects.GravityBomb;
|
||||
import nautilus.game.arcade.game.games.gravity.objects.GravityDebris;
|
||||
import nautilus.game.arcade.game.games.gravity.objects.GravityHook;
|
||||
import nautilus.game.arcade.game.games.gravity.objects.GravityPlayer;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
public class Gravity extends SoloGame
|
||||
@ -112,7 +113,7 @@ public class Gravity extends SoloGame
|
||||
|
||||
this.WorldTimeSet = 18000;
|
||||
|
||||
this.CompassEnabled = true;
|
||||
new CompassModule().register(this);
|
||||
|
||||
this.WorldBoundaryKill = false;
|
||||
|
||||
|
@ -27,6 +27,7 @@ import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType;
|
||||
import nautilus.game.arcade.game.games.milkcow.kits.KitCow;
|
||||
import nautilus.game.arcade.game.games.milkcow.kits.KitFarmerJump;
|
||||
import nautilus.game.arcade.game.games.milkcow.kits.KitSturdyFarmhand;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.NullKit;
|
||||
import net.minecraft.server.v1_8_R3.EntityCreature;
|
||||
@ -92,7 +93,7 @@ public class MilkCow extends SoloGame
|
||||
"First player to 15 points wins!"
|
||||
});
|
||||
|
||||
this.CompassEnabled = true;
|
||||
new CompassModule().register(this);
|
||||
this.DeathOut = false;
|
||||
|
||||
_scoreObj = Scoreboard.getScoreboard().registerNewObjective("Milk", "dummy");
|
||||
|
@ -246,10 +246,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
TeleportsDisqualify = false;
|
||||
GiveClock = false;
|
||||
|
||||
CompassEnabled = false;
|
||||
CompassGiveItem = false;
|
||||
CompassGiveItemSpectators = false;
|
||||
|
||||
Manager.GetCreature().SetDisableCustomDrops(true);
|
||||
|
||||
populateChallenges();
|
||||
|
@ -96,8 +96,6 @@ public class MonsterMaze extends SoloGame
|
||||
PrepareFreeze = false;
|
||||
|
||||
HungerSet = 20;
|
||||
|
||||
CompassEnabled = false;
|
||||
|
||||
registerStatTrackers(
|
||||
new SnowmanHitTracker(this),
|
||||
|
@ -85,7 +85,7 @@ public class QuiverTeamBase extends TeamGame
|
||||
getQuiverTeamModule(ModuleSpawnBarrier.class);
|
||||
getQuiverTeamModule(ModuleKillstreak.class);
|
||||
|
||||
registerModule(new VersionModule(MinecraftVersion.Version1_9, "One in the Quiver Payload requires Minecraft 1.9!"));
|
||||
new VersionModule(MinecraftVersion.Version1_9).register(this);
|
||||
|
||||
// if (WorldData.GetCustomLocs(CUSTOM_LOCATION_GAME_KOTH) != null)
|
||||
// {
|
||||
|
@ -114,7 +114,8 @@ public class KitSkyWarrior extends ProgressingKit
|
||||
new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(),
|
||||
new ItemBuilder(Material.BOW).setUnbreakable(true).build(),
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
private static final Achievement[] ACHIEVEMENTS =
|
||||
{
|
||||
Achievement.QUIVER_PAYLOAD_ASSASSIN,
|
||||
@ -123,12 +124,13 @@ public class KitSkyWarrior extends ProgressingKit
|
||||
Achievement.QUIVER_PAYLOAD_STEADY_HANDS,
|
||||
Achievement.QUIVER_PAYLOAD_UNSTOPPABLE
|
||||
};
|
||||
*/
|
||||
|
||||
public KitSkyWarrior(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Sky Warrior", "quiverskywarrior", KitAvailability.Achievement, 5000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
|
||||
|
||||
setAchievementRequirements(ACHIEVEMENTS);
|
||||
//setAchievementRequirements(ACHIEVEMENTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +76,7 @@ import nautilus.game.arcade.game.games.skyfall.stats.AeronaughtStatTracker;
|
||||
import nautilus.game.arcade.game.games.skyfall.stats.RingStatTracker;
|
||||
import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent;
|
||||
import nautilus.game.arcade.game.modules.VersionModule;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker;
|
||||
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
|
||||
@ -183,7 +184,7 @@ public abstract class Skyfall extends Game
|
||||
BlankLine
|
||||
);
|
||||
|
||||
registerModule(new VersionModule(MinecraftVersion.Version1_9, "Skyfall requires Minecraft 1.9!"));
|
||||
new VersionModule(MinecraftVersion.Version1_9).register(this);
|
||||
|
||||
// Disable specific GWEN checks for this game
|
||||
AntiHack antiHack = Managers.get(AntiHack.class);
|
||||
@ -214,8 +215,8 @@ public abstract class Skyfall extends Game
|
||||
DamageFall = false;
|
||||
SoupEnabled = true;
|
||||
StrictAntiHack = false;
|
||||
CompassEnabled = true;
|
||||
CompassGiveItem = false;
|
||||
|
||||
new CompassModule().register(this);
|
||||
|
||||
SpeedMeasurement = true;
|
||||
|
||||
|
@ -86,6 +86,7 @@ import nautilus.game.arcade.game.games.skywars.kits.KitEarth;
|
||||
import nautilus.game.arcade.game.games.skywars.kits.KitFire;
|
||||
import nautilus.game.arcade.game.games.skywars.kits.KitIce;
|
||||
import nautilus.game.arcade.game.games.skywars.kits.KitMetal;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.game.games.skywars.modes.kits.KitElementalist;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.ore.OreHider;
|
||||
@ -166,7 +167,7 @@ public abstract class Skywars extends Game
|
||||
|
||||
HideTeamSheep = true;
|
||||
|
||||
CompassEnabled = true;
|
||||
new CompassModule().register(this);
|
||||
|
||||
StrictAntiHack = true;
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class TeamSkywars extends Skywars
|
||||
TeamPerSpawn = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
registerModule(new TeamModule());
|
||||
new TeamModule().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,6 +79,7 @@ import nautilus.game.arcade.game.games.smash.kits.KitWitherSkeleton;
|
||||
import nautilus.game.arcade.game.games.smash.kits.KitWolf;
|
||||
import nautilus.game.arcade.game.games.smash.kits.KitZombie;
|
||||
import nautilus.game.arcade.game.games.smash.perks.SmashUltimate;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
|
||||
@ -120,11 +121,11 @@ public abstract class SuperSmash extends Game
|
||||
super(manager, type, kits, description);
|
||||
|
||||
DeathOut = false;
|
||||
CompassEnabled = true;
|
||||
DeathSpectateSecs = 4;
|
||||
WorldWaterDamage = 1000;
|
||||
HideTeamSheep = true;
|
||||
ReplaceTeamsWithKits = true;
|
||||
new CompassModule().register(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
@ -6,15 +6,18 @@ import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.modules.TeamModule;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
@ -37,13 +40,13 @@ public class TeamSuperSmash extends SuperSmash
|
||||
SpawnNearAllies = true;
|
||||
DamageTeamSelf = false;
|
||||
|
||||
TeamArmorHotbar = true;
|
||||
|
||||
DontAllowOverfill = true;
|
||||
|
||||
TeamMode = true;
|
||||
TeamArmorHotbar = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
registerModule(new TeamModule());
|
||||
|
||||
new TeamModule().register(this);
|
||||
|
||||
registerStatTrackers(new WinWithoutDyingStatTracker(this, "MLGPro"), new FreeKitWinStatTracker(this), new OneVThreeStatTracker(this), new KillFastStatTracker(this, 3, 10, "TripleKill"),
|
||||
new RecoveryMasterStatTracker(this));
|
||||
@ -96,6 +99,55 @@ public class TeamSuperSmash extends SuperSmash
|
||||
|
||||
Scoreboard.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void gameStart(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
super.gameStart(event);
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
GameTeam team = GetTeam(player);
|
||||
Player bestTeamMember = null;
|
||||
|
||||
if (team == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Player teamMember : team.GetPlayers(true))
|
||||
{
|
||||
if (player.equals(teamMember))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bestTeamMember = teamMember;
|
||||
}
|
||||
|
||||
if (bestTeamMember == null)
|
||||
{
|
||||
UtilTextMiddle.display(C.cRedB + "No one", "You don\'t have a teammate :(", 10, 50, 10, player);
|
||||
return;
|
||||
}
|
||||
|
||||
UtilTextMiddle.display(null, team.GetColor() + bestTeamMember.getName() + " is your teammate", 10, 50, 10, player);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(Manager.getPlugin(), 40);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCustomDamage(CustomDamageEvent event)
|
||||
|
@ -16,6 +16,7 @@ import nautilus.game.arcade.game.*;
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.kits.*;
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.npc.*;
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.powerups.*;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.*;
|
||||
import nautilus.game.arcade.stats.KillEntityStatTracker;
|
||||
import nautilus.game.arcade.stats.MasterAssassinStatTracker;
|
||||
@ -79,9 +80,10 @@ public class SneakyAssassins extends SoloGame
|
||||
this.PrepareFreeze = false;
|
||||
|
||||
this.HungerSet = 20;
|
||||
|
||||
this.CompassEnabled = true;
|
||||
this.CompassGiveItem = false;
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(false)
|
||||
.register(this);
|
||||
|
||||
Manager.getCosmeticManager().setHideParticles(true);
|
||||
|
||||
|
@ -30,6 +30,7 @@ import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitTactician;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitMedic;
|
||||
import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -84,9 +85,10 @@ public class SnowFight extends TeamGame
|
||||
this.PrepareFreeze = false;
|
||||
|
||||
this.HungerSet = 20;
|
||||
|
||||
this.CompassEnabled = true;
|
||||
this.CompassGiveItem = false;
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(false)
|
||||
.register(this);
|
||||
|
||||
this.TeamArmor = true;
|
||||
this.TeamArmorHotbar = true;
|
||||
|
@ -17,6 +17,7 @@ import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.quiver.QuiverScore;
|
||||
import nautilus.game.arcade.game.games.squidshooter.kits.*;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
public class SquidShooter extends SoloGame
|
||||
@ -46,7 +47,7 @@ public class SquidShooter extends SoloGame
|
||||
this.DamageSelf = false;
|
||||
this.DamageTeamSelf = true;
|
||||
this.PrepareFreeze = false;
|
||||
this.CompassEnabled = true;
|
||||
new CompassModule().register(this);
|
||||
this.KitRegisterState = GameState.Prepare;
|
||||
|
||||
registerChatStats();
|
||||
|
@ -187,8 +187,6 @@ public class SurvivalGamesTeams extends TeamGame
|
||||
|
||||
this.ItemDrop = true;
|
||||
this.ItemPickup = true;
|
||||
|
||||
this.CompassEnabled = false; //XXX
|
||||
|
||||
this.InventoryClick = true;
|
||||
this.InventoryOpenBlock = true;
|
||||
|
@ -50,7 +50,7 @@ public class TeamSurvivalGames extends SurvivalGames
|
||||
TeamMode = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
registerModule(new TeamModule());
|
||||
new TeamModule().register(this);
|
||||
|
||||
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
|
||||
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"),
|
||||
|
@ -121,7 +121,7 @@ public class TypeWars extends TeamGame
|
||||
this.DeathSpectateSecs = 0;
|
||||
this.HungerSet = 20;
|
||||
this.WorldBoundaryKill = true;
|
||||
this.CompassEnabled = false;
|
||||
|
||||
this.TeamArmor = true;
|
||||
this.TeamArmorHotbar = false;
|
||||
this.WorldTimeSet = 6000;
|
||||
|
@ -21,9 +21,9 @@ public class KitUHC extends ProgressingKit
|
||||
private static final Perk[] PERKS = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
private static final ItemStack IN_HAND = new ItemStack(Material.GOLD_SWORD);
|
||||
|
||||
|
||||
public KitUHC(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "UHC Player", "uhcplayer", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
|
||||
@ -33,6 +33,5 @@ public class KitUHC extends ProgressingKit
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,91 @@
|
||||
package nautilus.game.arcade.game.games.uhc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
|
||||
public class UHCSolo extends UHC
|
||||
{
|
||||
|
||||
public UHCSolo(ArcadeManager manager)
|
||||
{
|
||||
this(manager, GameType.UHCSolo);
|
||||
}
|
||||
|
||||
public UHCSolo(ArcadeManager manager, GameType type)
|
||||
{
|
||||
this(manager, type, false);
|
||||
}
|
||||
|
||||
public UHCSolo(ArcadeManager manager, GameType type, boolean speedMode)
|
||||
{
|
||||
super(manager, type, speedMode);
|
||||
|
||||
DamageTeamSelf = true;
|
||||
SpawnNearAllies = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerTeamGeneration(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Recruit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_teamList = new ArrayList<>(Arrays.asList(_teamList.get(0)));
|
||||
|
||||
for (GameTeam team : _teamList)
|
||||
{
|
||||
team.SetName("Players");
|
||||
team.SetColor(ChatColor.YELLOW);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getWinners()
|
||||
{
|
||||
if (GetState().ordinal() >= GameState.End.ordinal())
|
||||
{
|
||||
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
|
||||
if (places.isEmpty() || !places.get(0).isOnline())
|
||||
return Arrays.asList();
|
||||
else
|
||||
return Arrays.asList(places.get(0));
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getLosers()
|
||||
{
|
||||
List<Player> winners = getWinners();
|
||||
|
||||
if (winners == null)
|
||||
return null;
|
||||
|
||||
List<Player> losers = GetTeamList().get(0).GetPlayers(false);
|
||||
|
||||
losers.removeAll(winners);
|
||||
|
||||
return losers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetMode()
|
||||
{
|
||||
return "UHC Solo";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package nautilus.game.arcade.game.games.uhc;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
|
||||
public class UHCSoloSpeed extends UHCSolo
|
||||
{
|
||||
|
||||
public UHCSoloSpeed(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.UHCSoloSpeed, true);
|
||||
|
||||
MINING_TIME = (int) TimeUnit.MINUTES.toMillis(20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetMode()
|
||||
{
|
||||
return "UHC Solo Speed";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
package nautilus.game.arcade.game.games.uhc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.modules.TeamModule;
|
||||
|
||||
public class UHCTeams extends UHC
|
||||
{
|
||||
|
||||
public UHCTeams(ArcadeManager manager)
|
||||
{
|
||||
this(manager, GameType.UHC);
|
||||
}
|
||||
|
||||
public UHCTeams(ArcadeManager manager, GameType type)
|
||||
{
|
||||
this(manager, type, false);
|
||||
}
|
||||
|
||||
public UHCTeams(ArcadeManager manager, GameType type, boolean speedMode)
|
||||
{
|
||||
super(manager, type, speedMode);
|
||||
|
||||
FillTeamsInOrderToCount = 2;
|
||||
DamageTeamSelf = false;
|
||||
DontAllowOverfill = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
// Load the Team Module
|
||||
new TeamModule().register(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void PlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!InProgress())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
GameTeam team = GetTeam(player);
|
||||
if (team == null) return;
|
||||
|
||||
if (!team.IsAlive(player))
|
||||
return;
|
||||
|
||||
team.RemovePlayer(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void TeamRename(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
// Big Team
|
||||
if (team.GetSize() > 2)
|
||||
{
|
||||
team.SetName("Team " + team.GetName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = "";
|
||||
List<Player> players = team.GetPlayers(false);
|
||||
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
{
|
||||
Player player = players.get(i);
|
||||
|
||||
name += player.getName();
|
||||
|
||||
if (i < players.size() - 1)
|
||||
{
|
||||
name += " & ";
|
||||
}
|
||||
}
|
||||
|
||||
team.SetName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getWinners()
|
||||
{
|
||||
if (WinnerTeam == null)
|
||||
return null;
|
||||
|
||||
return WinnerTeam.GetPlayers(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getLosers()
|
||||
{
|
||||
if (WinnerTeam == null)
|
||||
return null;
|
||||
|
||||
List<Player> players = new ArrayList<>();
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (team != WinnerTeam)
|
||||
players.addAll(team.GetPlayers(false));
|
||||
}
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetMode()
|
||||
{
|
||||
return "UHC Teams";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package nautilus.game.arcade.game.games.uhc;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
|
||||
public class UHCTeamsSpeed extends UHCTeams
|
||||
{
|
||||
|
||||
public UHCTeamsSpeed(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.UHCTeamsSpeed, true);
|
||||
|
||||
MINING_TIME = (int) TimeUnit.MINUTES.toMillis(20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetMode()
|
||||
{
|
||||
return "UHC Teams Speed";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package nautilus.game.arcade.game.games.uhc.components;
|
||||
|
||||
import org.bukkit.WorldBorder;
|
||||
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
|
||||
public class UHCBorder
|
||||
{
|
||||
|
||||
private static final int WARNING_TIME = 60;
|
||||
|
||||
private UHC _host;
|
||||
private int _startingSize;
|
||||
|
||||
private WorldBorder _worldBorder;
|
||||
|
||||
public UHCBorder(UHC host, int startingSize)
|
||||
{
|
||||
_host = host;
|
||||
_startingSize = startingSize;
|
||||
}
|
||||
|
||||
public void prepare()
|
||||
{
|
||||
_worldBorder = _host.WorldData.World.getWorldBorder();
|
||||
|
||||
_worldBorder.setCenter(0, 0);
|
||||
_worldBorder.setWarningTime(WARNING_TIME);
|
||||
|
||||
setSize(_startingSize, 0);
|
||||
}
|
||||
|
||||
public void setSize(double size, long seconds)
|
||||
{
|
||||
_worldBorder.setSize(size * 2, seconds);
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
_worldBorder.setSize(_worldBorder.getSize());
|
||||
_worldBorder.setSize(99999);
|
||||
}
|
||||
|
||||
public double getSize()
|
||||
{
|
||||
if (_worldBorder == null)
|
||||
{
|
||||
return _startingSize;
|
||||
}
|
||||
|
||||
return _worldBorder.getSize();
|
||||
}
|
||||
|
||||
public double getMaxCords()
|
||||
{
|
||||
return getSize() / 2;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package nautilus.game.arcade.game.games.uhc.components;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
|
||||
public class UHCFreezer implements Listener
|
||||
{
|
||||
|
||||
private UHC _host;
|
||||
|
||||
private Set<UUID> _frozenPlayers = new HashSet<>();
|
||||
|
||||
public UHCFreezer(UHC host)
|
||||
{
|
||||
_host = host;
|
||||
|
||||
host.Manager.registerEvents(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void end(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.End)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.Unregister(this);
|
||||
}
|
||||
|
||||
public void freeze(Player player)
|
||||
{
|
||||
_frozenPlayers.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void unfreeze(Player player)
|
||||
{
|
||||
_frozenPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void unfreeze()
|
||||
{
|
||||
_frozenPlayers.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (!_host.IsLive() || !_frozenPlayers.contains(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
|
||||
if (from.getX() == to.getX() && from.getZ() == to.getZ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setTo(from);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package nautilus.game.arcade.game.games.uhc.components;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.game.modules.CutCleanModule;
|
||||
|
||||
public class UHCSpeedMode implements Listener
|
||||
{
|
||||
|
||||
// The max Y value that a player can have in order to have night vision.
|
||||
public static final long NIGHT_VISION_MAX_Y = 54;
|
||||
|
||||
// The rate that an apple will drop when breaking a leaves block
|
||||
public static final double APPLE_DROP_RATE = 0.1;
|
||||
|
||||
private static final ItemStack[] PLAYER_ITEMS = {
|
||||
new ItemStack(Material.STONE_SWORD),
|
||||
new ItemStack(Material.STONE_PICKAXE),
|
||||
new ItemStack(Material.STONE_AXE),
|
||||
new ItemStack(Material.STONE_SPADE),
|
||||
new ItemStack(Material.COOKED_BEEF, 10),
|
||||
new ItemStack(Material.WOOD, 32)
|
||||
};
|
||||
|
||||
private UHC _host;
|
||||
|
||||
public UHCSpeedMode(UHC host)
|
||||
{
|
||||
_host = host;
|
||||
|
||||
new CutCleanModule()
|
||||
.associateBlockDrop(Material.GOLD_ORE, new ItemBuilder(Material.GOLD_INGOT).build())
|
||||
.associateBlockDrop(Material.IRON_ORE, new ItemBuilder(Material.IRON_INGOT).build())
|
||||
.associateBlockDrop(Material.GRAVEL, new ItemStack(Material.FLINT))
|
||||
.associateMobDrop(Material.RAW_BEEF, new ItemBuilder(Material.COOKED_BEEF).build())
|
||||
.associateMobDrop(Material.RAW_CHICKEN, new ItemBuilder(Material.COOKED_CHICKEN).build())
|
||||
.associateMobDrop(Material.RAW_FISH, new ItemBuilder(Material.COOKED_FISH).build())
|
||||
.associateMobDrop(Material.PORK, new ItemBuilder(Material.GRILLED_PORK).build())
|
||||
.associateMobDrop(Material.RABBIT, new ItemBuilder(Material.COOKED_RABBIT).build())
|
||||
.associateMobDrop(Material.MUTTON, new ItemBuilder(Material.COOKED_MUTTON).build())
|
||||
.register(host);
|
||||
|
||||
host.Manager.registerEvents(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void start(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : _host.GetPlayers(true))
|
||||
{
|
||||
player.getInventory().addItem(PLAYER_ITEMS);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void end(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.End)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.Unregister(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void nightVision(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : _host.GetPlayers(true))
|
||||
{
|
||||
if (player.getLocation().getY() <= NIGHT_VISION_MAX_Y)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void appleDrop(BlockBreakEvent event)
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (block.getType() != Material.LEAVES)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Math.random() < APPLE_DROP_RATE)
|
||||
{
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.APPLE));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,385 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.uhc.helpers;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import net.minecraft.server.v1_8_R3.Chunk;
|
||||
import net.minecraft.server.v1_8_R3.ChunkProviderServer;
|
||||
import net.minecraft.server.v1_8_R3.ChunkRegionLoader;
|
||||
import net.minecraft.server.v1_8_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_8_R3.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.util.LongHash;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.spigotmc.AsyncCatcher;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static nautilus.game.arcade.game.games.uhc.UHC.VIEW_DISTANCE;
|
||||
|
||||
public class ChunkLoadingThread extends Thread implements Listener
|
||||
{
|
||||
private Game _game;
|
||||
|
||||
private volatile boolean _isDecorating = false;
|
||||
private AtomicInteger _actual = new AtomicInteger();
|
||||
private AtomicInteger _expected = new AtomicInteger(23000); // Most likely it'll be around 23000
|
||||
|
||||
private Set<net.minecraft.server.v1_8_R3.Entity> _entities = new HashSet<>();
|
||||
|
||||
public ChunkLoadingThread(Game game)
|
||||
{
|
||||
super("Chunk Loader");
|
||||
this._game = game;
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
WorldServer worldServer = ((CraftWorld) _game.WorldData.World).getHandle();
|
||||
Location spawn = _game.WorldData.World.getSpawnLocation();
|
||||
|
||||
Map<Long, Chunk> loaded = new ConcurrentHashMap<>();
|
||||
Map<Long, NBTTagCompound> compounds = new ConcurrentHashMap<>();
|
||||
|
||||
try
|
||||
{
|
||||
TimingManager.start("UHC Chunk Loading");
|
||||
|
||||
ChunkProviderServer chunkProviderServer = worldServer.chunkProviderServer;
|
||||
|
||||
Field chunkLoaderField = chunkProviderServer.getClass().getDeclaredField("chunkLoader");
|
||||
chunkLoaderField.setAccessible(true);
|
||||
|
||||
ChunkRegionLoader loader = (ChunkRegionLoader) chunkLoaderField.get(chunkProviderServer);
|
||||
|
||||
// Step 1: Read all the required chunks from the disk
|
||||
// We're going to read all the required chunks from disk async
|
||||
{
|
||||
Set<Long> coordPairs = new HashSet<>();
|
||||
|
||||
// Special case for 0, 0
|
||||
{
|
||||
int x = spawn.getBlockX() >> 4;
|
||||
int z = spawn.getBlockZ() >> 4;
|
||||
|
||||
for (int dx = -VIEW_DISTANCE; dx <= VIEW_DISTANCE; dx++)
|
||||
{
|
||||
for (int dz = -VIEW_DISTANCE; dz <= VIEW_DISTANCE; dz++)
|
||||
{
|
||||
coordPairs.add(LongHash.toLong(x + dx, z + dz));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All the team spawns
|
||||
{
|
||||
for (int i = 0; i < _game.GetTeamList().size(); i++)
|
||||
{
|
||||
GameTeam team = _game.GetTeamList().get(i);
|
||||
for (Location l : team.GetSpawns())
|
||||
{
|
||||
int x = l.getChunk().getX();
|
||||
int z = l.getChunk().getZ();
|
||||
|
||||
for (int dx = -VIEW_DISTANCE; dx <= VIEW_DISTANCE; dx++)
|
||||
{
|
||||
for (int dz = -VIEW_DISTANCE; dz <= VIEW_DISTANCE; dz++)
|
||||
{
|
||||
coordPairs.add(LongHash.toLong(x + dx, z + dz));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AtomicBoolean lockCompleted = new AtomicBoolean(false);
|
||||
Object lock = new Object();
|
||||
|
||||
// Hop back onto the main thread
|
||||
_game.getArcadeManager().runSync(() ->
|
||||
{
|
||||
for (Chunk chunk : new ArrayList<>(chunkProviderServer.chunks.values()))
|
||||
{
|
||||
chunk.bukkitChunk.unload(true, false);
|
||||
}
|
||||
lockCompleted.set(true);
|
||||
synchronized(lock)
|
||||
{
|
||||
lock.notifyAll();
|
||||
}
|
||||
});
|
||||
if (!lockCompleted.get())
|
||||
{
|
||||
synchronized (lock)
|
||||
{
|
||||
lock.wait();
|
||||
}
|
||||
}
|
||||
if (!lockCompleted.get())
|
||||
{
|
||||
throw new IllegalStateException("Lock was not completed");
|
||||
}
|
||||
|
||||
|
||||
// Sigh... I don't want this to be here but it needs to be set somewhere...
|
||||
// Multiply by 3 because there are 3 stages
|
||||
_expected.set(coordPairs.size() * 3);
|
||||
|
||||
// Load them now
|
||||
ExecutorService chunkLoaders = Executors.newFixedThreadPool(UHC.THREADS_FOR_CHUNK_LOADING);
|
||||
|
||||
for (long coord : coordPairs)
|
||||
{
|
||||
chunkLoaders.submit(() ->
|
||||
{
|
||||
int x = LongHash.msw(coord);
|
||||
int z = LongHash.lsw(coord);
|
||||
try
|
||||
{
|
||||
Object[] data = loader.loadChunk(worldServer, x, z);
|
||||
if (data != null)
|
||||
{
|
||||
NBTTagCompound compound = (NBTTagCompound) data[1];
|
||||
net.minecraft.server.v1_8_R3.Chunk chunk = (net.minecraft.server.v1_8_R3.Chunk) data[0];
|
||||
loaded.put(coord, chunk);
|
||||
compounds.put(coord, compound);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Failed to load chunk " + x + "," + z);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_actual.getAndIncrement();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
chunkLoaders.shutdown();
|
||||
|
||||
// We've got plenty of time to wait
|
||||
System.out.println("Finished submitting tasks to executor, waiting...");
|
||||
chunkLoaders.awaitTermination(1, TimeUnit.DAYS);
|
||||
|
||||
System.out.println("Loaded: " + loaded.size() + " and coords: " + coordPairs.size());
|
||||
coordPairs.clear();
|
||||
}
|
||||
|
||||
// Step 2: Recreate structures, update neighbors, load entities
|
||||
// This step should be super quick so there's no point in scheduling it elsewhere
|
||||
// Code is plain copypasted from ChunkIOProvider
|
||||
{
|
||||
for (net.minecraft.server.v1_8_R3.Chunk chunk : loaded.values())
|
||||
{
|
||||
NBTTagCompound compound = compounds.get(LongHash.toLong(chunk.locX, chunk.locZ));
|
||||
loader.loadEntities(chunk, compound.getCompound("Level"), worldServer);
|
||||
chunk.setLastSaved(chunkProviderServer.world.getTime());
|
||||
if (chunkProviderServer.chunkProvider != null)
|
||||
{
|
||||
chunkProviderServer.chunkProvider.recreateStructures(chunk, chunk.locX, chunk.locZ);
|
||||
}
|
||||
|
||||
for (int x = -2; x < 3; ++x)
|
||||
{
|
||||
for (int z = -2; z < 3; ++z)
|
||||
{
|
||||
if (x != 0 || z != 0)
|
||||
{
|
||||
net.minecraft.server.v1_8_R3.Chunk neighbor = loaded.get(LongHash.toLong(chunk.locX + x, chunk.locZ + z));
|
||||
if (neighbor != null)
|
||||
{
|
||||
neighbor.setNeighborLoaded(-x, -z);
|
||||
chunk.setNeighborLoaded(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_actual.getAndIncrement();
|
||||
}
|
||||
}
|
||||
|
||||
AtomicBoolean lockCompleted = new AtomicBoolean(false);
|
||||
Object lock = new Object();
|
||||
|
||||
// Hop back onto the main thread
|
||||
_game.getArcadeManager().runSync(() ->
|
||||
{
|
||||
// We want to add all the chunks to the chunkmap so that the server is not out of sync
|
||||
for (Map.Entry<Long, net.minecraft.server.v1_8_R3.Chunk> ent : loaded.entrySet())
|
||||
{
|
||||
ent.getValue().addEntities();
|
||||
chunkProviderServer.chunks.put(ent.getKey(), ent.getValue());
|
||||
ChunkLoadEvent event = new ChunkLoadEvent(ent.getValue().bukkitChunk, true);
|
||||
UtilServer.CallEvent(event);
|
||||
}
|
||||
lockCompleted.set(true);
|
||||
synchronized (lock)
|
||||
{
|
||||
lock.notifyAll();
|
||||
}
|
||||
});
|
||||
|
||||
if (!lockCompleted.get())
|
||||
{
|
||||
synchronized (lock)
|
||||
{
|
||||
lock.wait();
|
||||
}
|
||||
}
|
||||
if (!lockCompleted.get())
|
||||
{
|
||||
throw new IllegalStateException("Lock was not completed");
|
||||
}
|
||||
|
||||
|
||||
// Step 3: Decorate the chunks. This step must be performed async as otherwise the server lags way too hard
|
||||
// Notes: Do not allow the server to tick the world. If this is allowed EntityTracker will raise CME
|
||||
// NextTickList will also raise errors
|
||||
// And worst case the server will crash
|
||||
{
|
||||
// Live life on the edge
|
||||
AsyncCatcher.enabled = false;
|
||||
_isDecorating = true;
|
||||
int ct = 0;
|
||||
for (net.minecraft.server.v1_8_R3.Chunk chunk : loaded.values())
|
||||
{
|
||||
chunk.loadNearby(chunkProviderServer, chunkProviderServer, chunk.locX, chunk.locZ);
|
||||
ct++;
|
||||
if (ct % 100 == 0)
|
||||
{
|
||||
System.out.println(ct);
|
||||
}
|
||||
_actual.getAndIncrement();
|
||||
}
|
||||
|
||||
TimingManager.stop("UHC Chunk Loading");
|
||||
_isDecorating = false;
|
||||
AsyncCatcher.enabled = true;
|
||||
|
||||
System.out.println("Expected: " + _expected.get() + ", actual: " + _actual.get());
|
||||
|
||||
_game.getArcadeManager().runSync(() ->
|
||||
{
|
||||
|
||||
for (Chunk chunk : chunkProviderServer.chunks.values())
|
||||
{
|
||||
// Clear
|
||||
for (int x = -2; x < 3; x++) {
|
||||
for (int z = -2; z < 3; z++) {
|
||||
if (x == 0 && z == 0) {
|
||||
continue;
|
||||
}
|
||||
chunk.setNeighborUnloaded(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Chunk chunk : chunkProviderServer.chunks.values())
|
||||
{
|
||||
// Refresh
|
||||
for (int x = -2; x < 3; x++) {
|
||||
for (int z = -2; z < 3; z++) {
|
||||
if (x == 0 && z == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Chunk neighbor = chunkProviderServer.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
|
||||
if (neighbor != null) {
|
||||
neighbor.setNeighborLoaded(-x, -z);
|
||||
chunk.setNeighborLoaded(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (net.minecraft.server.v1_8_R3.Entity entity : _entities)
|
||||
{
|
||||
entity.dead = false;
|
||||
worldServer.addEntity(entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
|
||||
}
|
||||
|
||||
_entities.clear();
|
||||
|
||||
// You may tick again
|
||||
worldServer.getMinecraftServer().worlds.add(worldServer);
|
||||
|
||||
// Well, if they're not equal, not much we can do. We've hit the end
|
||||
_actual.set(_expected.get());
|
||||
});
|
||||
}
|
||||
|
||||
loaded.clear();
|
||||
compounds.clear();
|
||||
|
||||
UtilServer.Unregister(this);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(EntitySpawnEvent event)
|
||||
{
|
||||
// Don't allow entity spawns while decorating, period
|
||||
if (_isDecorating)
|
||||
{
|
||||
if (event.getLocation().getWorld().getUID() == _game.WorldData.World.getUID())
|
||||
{
|
||||
_entities.add(((CraftEntity) event.getEntity()).getHandle());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void flagDone()
|
||||
{
|
||||
_actual.set(_expected.get());
|
||||
}
|
||||
|
||||
public boolean isDone()
|
||||
{
|
||||
return _actual.get() == _expected.get();
|
||||
}
|
||||
|
||||
public int getPercentageComplete()
|
||||
{
|
||||
return UtilMath.clamp((int) ((_actual.get() * 1.0 / _expected.get()) * 100), 0, 100);
|
||||
}
|
||||
|
||||
public String getProgress()
|
||||
{
|
||||
return getPercentageComplete() + "%";
|
||||
}
|
||||
|
||||
public void flagStop()
|
||||
{
|
||||
this.interrupt();
|
||||
}
|
||||
}
|
@ -1,225 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.uhc.helpers;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import net.minecraft.server.v1_8_R3.BiomeCache;
|
||||
import net.minecraft.server.v1_8_R3.ChunkProviderServer;
|
||||
import net.minecraft.server.v1_8_R3.FileIOThread;
|
||||
import net.minecraft.server.v1_8_R3.IChunkProvider;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
import net.minecraft.server.v1_8_R3.WorldChunkManager;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.util.LongHash;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class WorldGenThread extends Thread
|
||||
{
|
||||
private UHC _game;
|
||||
|
||||
private volatile boolean _mapLoaded = false;
|
||||
private volatile int _chunksPerTick = 1;
|
||||
private volatile boolean _stopGen = false;
|
||||
|
||||
private int _chunkTotal;
|
||||
private int _chunkX = 0;
|
||||
private int _chunkZ = 0;
|
||||
private int _chunksLoaded = 0;
|
||||
|
||||
private int _currentBorder = 1000;
|
||||
|
||||
|
||||
public WorldGenThread(UHC game)
|
||||
{
|
||||
super("WorldGen Thread");
|
||||
this._game = game;
|
||||
|
||||
|
||||
_chunkX = (int) -(_currentBorder / 16);
|
||||
_chunkZ = (int) -(_currentBorder / 16);
|
||||
_chunkTotal = (int) ((_currentBorder * 2 / 16) * (_currentBorder * 2 / 16));
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Field fileIOThreadB = FileIOThread.class.getDeclaredField("b");
|
||||
fileIOThreadB.setAccessible(true);
|
||||
|
||||
// This list is the list of chunks to be saved on the File IO Thread
|
||||
List list = (List) fileIOThreadB.get(FileIOThread.a());
|
||||
|
||||
net.minecraft.server.v1_8_R3.WorldServer worldServer = ((CraftWorld) _game.WorldData.World).getHandle();
|
||||
|
||||
WorldChunkManager manager = worldServer.getWorldChunkManager();
|
||||
|
||||
Field biomeCacheField = manager.getClass().getDeclaredField("d");
|
||||
biomeCacheField.setAccessible(true);
|
||||
|
||||
// A thread safe BiomeCache
|
||||
// The implementation is literally a copy/paste from the original BiomeCache, but with some synchronization
|
||||
// Reason being while the server is ticking the world (for some reason, if you want to dig through the entire Arcade codebase go for it)
|
||||
// it stores stuff in the BiomeCache, and chunk gen needs that BiomeCache info too
|
||||
// Causing desynchronization in the cache
|
||||
biomeCacheField.set(manager, new BiomeCache(manager)
|
||||
{
|
||||
private final Object _lock = new Object();
|
||||
|
||||
private long _lastCleanTime; // b -> _lastCleanTime
|
||||
private Map<Long, BiomeCacheBlock> _blockByCoord = new HashMap<>(); // LongHashMap -> HashMap, c -> _blockByCoord
|
||||
private List<BiomeCache.BiomeCacheBlock> _blocks = new ArrayList<>(); // d -> _blocks
|
||||
|
||||
@Override
|
||||
public BiomeCache.BiomeCacheBlock a(int x, int z)
|
||||
{
|
||||
x >>= 4;
|
||||
z >>= 4;
|
||||
long var3 = hash(x, z);
|
||||
BiomeCache.BiomeCacheBlock var5 = this._blockByCoord.get(var3);
|
||||
if (var5 == null)
|
||||
{
|
||||
var5 = new BiomeCache.BiomeCacheBlock(x, z);
|
||||
synchronized (_lock)
|
||||
{
|
||||
this._blockByCoord.put(var3, var5);
|
||||
this._blocks.add(var5);
|
||||
}
|
||||
}
|
||||
|
||||
var5.e = MinecraftServer.az();
|
||||
return var5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a()
|
||||
{
|
||||
long currentTime = MinecraftServer.az();
|
||||
long deltaTime = currentTime - this._lastCleanTime;
|
||||
if (deltaTime > 7500L || deltaTime < 0L)
|
||||
{
|
||||
this._lastCleanTime = currentTime;
|
||||
|
||||
synchronized (_lock)
|
||||
{
|
||||
for (int i = 0; i < this._blocks.size(); ++i)
|
||||
{
|
||||
BiomeCache.BiomeCacheBlock biomeCacheBlock = (BiomeCache.BiomeCacheBlock) this._blocks.get(i);
|
||||
long var7 = currentTime - biomeCacheBlock.e;
|
||||
if (var7 > 30000L || var7 < 0L)
|
||||
{
|
||||
this._blocks.remove(i--);
|
||||
this._blockByCoord.remove(hash(biomeCacheBlock.c, biomeCacheBlock.d));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long hash(int x, int z)
|
||||
{
|
||||
return (long) x & 4294967295L | ((long) z & 4294967295L) << 32;
|
||||
}
|
||||
});
|
||||
|
||||
ChunkProviderServer cps = worldServer.chunkProviderServer;
|
||||
IChunkProvider icp = cps.chunkProvider;
|
||||
System.out.println("Using chunk provider " + icp.getClass());
|
||||
|
||||
TimingManager.start("Map Generation");
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
while (!_stopGen)
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
long hash = LongHash.toLong(_chunkX, _chunkZ);
|
||||
|
||||
// This is just a shortcut to how the Minecraft server would have generated a chunk if it doesn't exist.
|
||||
// This should always create a chunk because we're not loading any chunks beforehand...
|
||||
// /me looks at new maintainer
|
||||
net.minecraft.server.v1_8_R3.Chunk chunk = icp.getOrCreateChunk(_chunkX, _chunkZ);
|
||||
|
||||
// Run the copypasted code for chunk saving.
|
||||
cps.saveChunk(chunk);
|
||||
cps.saveChunkNOP(chunk);
|
||||
cps.unloadQueue.remove(_chunkX, _chunkZ);
|
||||
cps.chunks.remove(hash);
|
||||
|
||||
if (_chunkX < _currentBorder / 16)
|
||||
{
|
||||
_chunkX++;
|
||||
}
|
||||
else if (_chunkZ < _currentBorder / 16)
|
||||
{
|
||||
_chunkX = (int) -(_currentBorder / 16);
|
||||
_chunkZ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapLoaded = true;
|
||||
break;
|
||||
}
|
||||
|
||||
_chunksLoaded++;
|
||||
|
||||
_chunksPerTick = (int) (_chunksLoaded / ((now - start) / 50.0));
|
||||
}
|
||||
|
||||
TimingManager.stop("Map Generation");
|
||||
|
||||
if (_stopGen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TimingManager.start("Map Saving");
|
||||
|
||||
// Wait for all the chunks to save (but do we need this?)
|
||||
while (!list.isEmpty())
|
||||
{
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
TimingManager.stop("Map Saving");
|
||||
|
||||
_game.getArcadeManager().runSync(_game::generateSpawns);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// todo proper exception handling
|
||||
// maybe force shutdown?
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void flagStop()
|
||||
{
|
||||
this._stopGen = true;
|
||||
}
|
||||
|
||||
public boolean isMapLoaded()
|
||||
{
|
||||
return this._mapLoaded;
|
||||
}
|
||||
|
||||
public int getPercentageComplete()
|
||||
{
|
||||
return UtilMath.clamp((int) ((_chunksLoaded * 1.0 / _chunkTotal) * 100), 0, 100);
|
||||
}
|
||||
|
||||
public String getProgress()
|
||||
{
|
||||
return getPercentageComplete() + "%";
|
||||
}
|
||||
}
|
@ -12,17 +12,19 @@ import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.uhc.UHCSolo;
|
||||
|
||||
/**
|
||||
* Assassins gamemode for UHC
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class Assassins extends UHC
|
||||
public class Assassins extends UHCSolo
|
||||
{
|
||||
|
||||
private HashMap<Player, Player> _assassins;
|
||||
|
@ -8,14 +8,14 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.game.games.uhc.UHCSolo;
|
||||
|
||||
/**
|
||||
* BloodDiamonds gamemode for UHC
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class BloodDiamonds extends UHC
|
||||
public class BloodDiamonds extends UHCSolo
|
||||
{
|
||||
|
||||
private HashMap<Material, Double> _oreDamage;
|
||||
|
@ -1,68 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.uhc.modes;
|
||||
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.game.modules.CutCleanModule;
|
||||
import nautilus.game.arcade.game.modules.ItemGiverModule;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/*
|
||||
* The CutClean variant of UHC
|
||||
*
|
||||
* This is identical to UHC however iron and gold ore will immediately smelt
|
||||
* and mob drops will be immediately cooked
|
||||
*/
|
||||
public class CutClean extends UHC
|
||||
{
|
||||
// The amount of steak to give at the start of the game
|
||||
private static final int STEAK_AMOUNT = 15;
|
||||
|
||||
public CutClean(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Brawl);
|
||||
|
||||
registerModule(new CutCleanModule()
|
||||
.associateBlockDrop(
|
||||
Material.GOLD_ORE,
|
||||
new ItemBuilder(Material.GOLD_INGOT).build()
|
||||
)
|
||||
.associateBlockDrop(
|
||||
Material.IRON_ORE,
|
||||
new ItemBuilder(Material.IRON_INGOT).build()
|
||||
)
|
||||
.associateMobDrop(
|
||||
Material.RAW_BEEF,
|
||||
new ItemBuilder(Material.COOKED_BEEF).build()
|
||||
)
|
||||
.associateMobDrop(
|
||||
Material.RAW_CHICKEN,
|
||||
new ItemBuilder(Material.COOKED_CHICKEN).build()
|
||||
)
|
||||
.associateMobDrop(
|
||||
Material.RAW_FISH,
|
||||
new ItemBuilder(Material.COOKED_FISH).build()
|
||||
)
|
||||
.associateMobDrop(
|
||||
Material.PORK,
|
||||
new ItemBuilder(Material.GRILLED_PORK).build()
|
||||
)
|
||||
.associateMobDrop(
|
||||
Material.RABBIT,
|
||||
new ItemBuilder(Material.COOKED_RABBIT).build()
|
||||
)
|
||||
);
|
||||
|
||||
registerModule(new ItemGiverModule()
|
||||
.withItem(new ItemStack(Material.COOKED_BEEF, STEAK_AMOUNT))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetMode()
|
||||
{
|
||||
return "Cut Clean";
|
||||
}
|
||||
}
|
@ -1,28 +1,31 @@
|
||||
package nautilus.game.arcade.game.games.uhc.modes;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.game.modules.CutCleanModule;
|
||||
import nautilus.game.arcade.game.modules.ItemGiverModule;
|
||||
import nautilus.game.arcade.game.modules.OreVeinEditorModule;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.games.uhc.UHCSolo;
|
||||
import nautilus.game.arcade.game.modules.CutCleanModule;
|
||||
import nautilus.game.arcade.game.modules.ItemGiverModule;
|
||||
import nautilus.game.arcade.game.modules.OreVeinEditorModule;
|
||||
|
||||
/**
|
||||
* GodBattles gamemode for UHC
|
||||
*/
|
||||
public class GodBattles extends UHC
|
||||
public class GodBattles extends UHCSolo
|
||||
{
|
||||
// The set of materials which will be considered as an ore
|
||||
private static final Set<Material> ORE_MATERIALS = Sets.newHashSet(
|
||||
@ -43,18 +46,18 @@ public class GodBattles extends UHC
|
||||
{
|
||||
super(manager, GameType.Brawl);
|
||||
|
||||
registerModule(new CutCleanModule()
|
||||
new CutCleanModule()
|
||||
.associateBlockDrop(
|
||||
Material.GOLD_ORE,
|
||||
new ItemBuilder(Material.GOLD_BLOCK).build()
|
||||
)
|
||||
);
|
||||
.register(this);
|
||||
|
||||
registerModule(new ItemGiverModule()
|
||||
new ItemGiverModule()
|
||||
.withItem(UtilItem.makeUnbreakable(new ItemStack(Material.DIAMOND_PICKAXE)))
|
||||
);
|
||||
.register(this);
|
||||
|
||||
registerModule(new OreVeinEditorModule()
|
||||
new OreVeinEditorModule()
|
||||
.useFilter(block -> ORE_MATERIALS.contains(block.getType()))
|
||||
.useEditor(vein ->
|
||||
{
|
||||
@ -68,7 +71,7 @@ public class GodBattles extends UHC
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,7 +122,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
|
||||
this.DeathSpectateSecs = 4;
|
||||
this.HungerSet = 20;
|
||||
this.WorldBoundaryKill = false;
|
||||
this.CompassEnabled = false;
|
||||
|
||||
//Customizing for the Editor kit
|
||||
this.BlockBreak = true;
|
||||
|
@ -32,6 +32,7 @@ import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.games.zombiesurvival.kits.*;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.NullKit;
|
||||
import net.minecraft.server.v1_8_R3.EntityCreature;
|
||||
@ -68,8 +69,8 @@ public class ZombieSurvival extends SoloGame
|
||||
|
||||
this.DeathOut = false;
|
||||
this.HungerSet = 20;
|
||||
|
||||
this.CompassEnabled = true;
|
||||
|
||||
new CompassModule().register(this);
|
||||
|
||||
registerChatStats(
|
||||
Kills,
|
||||
|
@ -1,24 +1,26 @@
|
||||
package nautilus.game.arcade.game.modules;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import mineplex.core.Managers;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/*
|
||||
/**
|
||||
* This is a Module
|
||||
*
|
||||
* <p>
|
||||
* A Module represents something which will enhance or change the way games can be played.
|
||||
* Modules should function independent of which specific gamemode is being played.
|
||||
* If you need game-specific features, put it into that Game implementation or refactor it into a separate class (not a module).
|
||||
*
|
||||
* If you need game-specific features, put it into that Game implementation or refactor it into a separate class (not a module).
|
||||
* <p>
|
||||
* Modules should never directly access other Modules via the Game instance.
|
||||
* Instead, the game which requires cross-contamination should do so itself.
|
||||
*
|
||||
* Instead, the game which requires cross-contamination should do so itself.
|
||||
* <p>
|
||||
* Modules should be associated per-game. Do not make them static
|
||||
*
|
||||
* <p>
|
||||
* If your module is able to accept custom configuration, override the configure(JsonElement) method
|
||||
* You can define the format of the json you wish to use.
|
||||
* You can define the format of the json you wish to use.
|
||||
* This custom configuration will be used to dynamically adjust gamemodes via Redis if needed
|
||||
*/
|
||||
public abstract class Module implements Listener
|
||||
@ -26,10 +28,10 @@ public abstract class Module implements Listener
|
||||
// The game this module belongs to
|
||||
private Game _game;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Initializes this module with the specific game instance. You should never do this as {@link Game} does it for you
|
||||
*/
|
||||
public void initialize(Game game)
|
||||
public final void initialize(Game game)
|
||||
{
|
||||
if (_game != null)
|
||||
{
|
||||
@ -39,33 +41,35 @@ public abstract class Module implements Listener
|
||||
this.setup();
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is called once initialization is complete. Do whatever you need to do with the {@link Game} here
|
||||
/**
|
||||
* This method is called once initialization is complete. Do whatever you need to do with the {@link Game} here.
|
||||
*
|
||||
* All modules should have been configured before this method is called
|
||||
*/
|
||||
protected void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* If this module can be configured via a JsonObject/JsonPrimitive, then override this method
|
||||
* to implement that feature
|
||||
*
|
||||
* to implement that feature
|
||||
* <p>
|
||||
* You can define how the JsonElement should be formatted.
|
||||
*
|
||||
* <p>
|
||||
* It is recommended to have a "force" boolean which will reset this module to a clean state
|
||||
* (to allow extensive customization using json)
|
||||
* (to allow extensive customization using json)
|
||||
*/
|
||||
public void configure(JsonElement element)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* This method is called once this module is no longer needed.
|
||||
* This could be because the game is over
|
||||
* Or because this module was unregistered
|
||||
*
|
||||
* This could be because the game is over
|
||||
* Or because this module was unregistered
|
||||
* <p>
|
||||
* The {@link Game} will unregister this module as a listener for you.
|
||||
* All you need to do is clean up after yourself
|
||||
*/
|
||||
@ -74,11 +78,16 @@ public abstract class Module implements Listener
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Gets the game this module is associated with
|
||||
*/
|
||||
public Game getGame()
|
||||
{
|
||||
return this._game;
|
||||
}
|
||||
|
||||
public final void register(Game instance)
|
||||
{
|
||||
instance.registerModule(this);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package nautilus.game.arcade.game.modules;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -0,0 +1,169 @@
|
||||
package nautilus.game.arcade.game.modules;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.CraftingInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
|
||||
public class PlayerHeadModule extends Module
|
||||
{
|
||||
private boolean _disableCraftingRegularApples = true;
|
||||
private boolean _disableHeadPlace = true;
|
||||
|
||||
@Override
|
||||
protected void setup()
|
||||
{
|
||||
ShapedRecipe headApple2 = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1));
|
||||
headApple2.shape("GGG", "GHG", "GGG");
|
||||
headApple2.setIngredient('G', Material.GOLD_INGOT);
|
||||
headApple2.setIngredient('H', new MaterialData(Material.SKULL_ITEM, (byte) 2));
|
||||
UtilServer.getServer().addRecipe(headApple2);
|
||||
}
|
||||
|
||||
public PlayerHeadModule enableCraftingRegularApples()
|
||||
{
|
||||
this._disableCraftingRegularApples = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerHeadModule enableHeadPlace()
|
||||
{
|
||||
this._disableHeadPlace = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableHeadPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if ((event.getItemInHand().getType() == Material.SKULL || event.getItemInHand().getType() == Material.SKULL_ITEM) &&
|
||||
this._disableHeadPlace)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void headPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (!getGame().IsLive())
|
||||
return;
|
||||
|
||||
if (event.getItem().getItemStack().getType() == Material.SKULL_ITEM)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), " ");
|
||||
UtilPlayer.message(event.getPlayer(), C.cGreen + C.Bold + "You picked up a Golden Head!");
|
||||
UtilPlayer.message(event.getPlayer(), C.cWhite + "Craft a Golden Head Apple with it for ultimate healing.");
|
||||
UtilPlayer.message(event.getPlayer(), C.cWhite + "Use the recipe for Golden Apple, but Head replaces Apple.");
|
||||
UtilPlayer.message(event.getPlayer(), " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void PlayerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Player player = event.getEntity();
|
||||
|
||||
GameTeam team = getGame().GetTeam(player);
|
||||
if (team == null)
|
||||
return;
|
||||
|
||||
event.getDrops().add(getGoldenHead());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void eatHeadApple(PlayerItemConsumeEvent event)
|
||||
{
|
||||
if (event.getItem().getItemMeta().getDisplayName() == null)
|
||||
return;
|
||||
|
||||
if (!event.getItem().getItemMeta().getDisplayName().contains("Head"))
|
||||
return;
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), "You ate " + event.getItem().getItemMeta().getDisplayName());
|
||||
|
||||
(new PotionEffect(PotionEffectType.ABSORPTION, 2400, 0)).apply(event.getPlayer());
|
||||
(new PotionEffect(PotionEffectType.REGENERATION, 200, 1)).apply(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void denyGoldApple(PrepareItemCraftEvent event)
|
||||
{
|
||||
if (event.getRecipe().getResult() == null)
|
||||
return;
|
||||
|
||||
Material type = event.getRecipe().getResult().getType();
|
||||
|
||||
if (type != Material.GOLDEN_APPLE)
|
||||
return;
|
||||
|
||||
CraftingInventory inv = event.getInventory();
|
||||
|
||||
for (ItemStack item : inv.getMatrix())
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
if (item.getType() == Material.GOLD_INGOT)
|
||||
return;
|
||||
|
||||
inv.setResult(null);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void craftHeadApple(PrepareItemCraftEvent event)
|
||||
{
|
||||
if (event.getRecipe().getResult() == null)
|
||||
return;
|
||||
|
||||
Material type = event.getRecipe().getResult().getType();
|
||||
|
||||
if (type != Material.GOLDEN_APPLE)
|
||||
return;
|
||||
|
||||
CraftingInventory inv = event.getInventory();
|
||||
|
||||
for (ItemStack item : inv.getMatrix())
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
if (item.getType() == Material.SKULL_ITEM || item.getType() == Material.SKULL)
|
||||
{
|
||||
if (item.getItemMeta() == null)
|
||||
continue;
|
||||
|
||||
if (item.getItemMeta().getDisplayName() == null)
|
||||
continue;
|
||||
|
||||
ItemStack apple = ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE, (byte) 0, 1, item
|
||||
.getItemMeta().getDisplayName() + ChatColor.AQUA + " Golden Apple");
|
||||
apple.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
|
||||
|
||||
inv.setResult(apple);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static final ItemStack getGoldenHead()
|
||||
{
|
||||
return new ItemBuilder(Material.SKULL_ITEM)
|
||||
.setData((short) 2)
|
||||
.setAmount(1)
|
||||
.setTitle(C.cGoldB + "Player Head")
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,310 @@
|
||||
package nautilus.game.arcade.game.modules;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import nautilus.game.arcade.game.DebugCommand;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
public class RejoinModule extends Module
|
||||
{
|
||||
|
||||
private Set<RejoinPlayerData> _data = new HashSet<>();
|
||||
|
||||
private int _rejoinTime = (int) TimeUnit.MINUTES.toMillis(2);
|
||||
|
||||
@Override
|
||||
protected void setup()
|
||||
{
|
||||
getGame().registerDebugCommand(new DebugCommand("rejoin", Rank.ADMIN)
|
||||
{
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
caller.sendMessage(F.main("Debug", "/rejoin <name>"));
|
||||
return;
|
||||
}
|
||||
|
||||
String player = args[0];
|
||||
|
||||
RejoinPlayerData data = getRejoinPlayerData(player);
|
||||
|
||||
// Player wasn't alive earlier or was too slow
|
||||
if (data == null)
|
||||
{
|
||||
_data.add(new RejoinPlayerData(player, 20, null, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main("Debug", "That player is already allowed to rejoin!"));
|
||||
return;
|
||||
}
|
||||
|
||||
caller.sendMessage(F.main("Debug", C.cYellow + player + C.cGray + " is now allowed to rejoin. If they are online tell them to relog."));
|
||||
caller.sendMessage(F.main("Debug", "There are issues with this and it should not be used outside of the testing environment!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
GameTeam team = getGame().GetTeam(player);
|
||||
|
||||
if (team == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!team.IsAlive(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getWorld().getName().equalsIgnoreCase("world"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (getGame().QuitOut)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_data.add(new RejoinPlayerData(player.getName(), player.getHealth(), getGame().GetKit(player), team));
|
||||
|
||||
NautHashMap<String, Location> location = getGame().GetLocationStore();
|
||||
|
||||
if (!location.containsKey(player.getName()))
|
||||
{
|
||||
location.put(player.getName(), player.getLocation());
|
||||
}
|
||||
|
||||
team.RemovePlayer(player);
|
||||
|
||||
// Announcement
|
||||
getGame().Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! " + UtilTime.MakeStr(_rejoinTime) + " to rejoin.", false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerRejoinGame(PlayerLoginEvent event)
|
||||
{
|
||||
if (!getGame().InProgress() || getGame().QuitOut)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
RejoinPlayerData data = getRejoinPlayerData(player.getName());
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_data.remove(data);
|
||||
|
||||
GameTeam team = data.getTeam();
|
||||
|
||||
// Assume they have been revived
|
||||
if (data.getTeam() == null)
|
||||
{
|
||||
team = UtilAlg.Random(getGame().GetTeamList());
|
||||
}
|
||||
|
||||
team.AddPlayer(player, true);
|
||||
getGame().Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!", false);
|
||||
|
||||
if (data.getKit() != null)
|
||||
{
|
||||
getGame().SetKit(player, data.getKit(), false);
|
||||
}
|
||||
}
|
||||
|
||||
// Do this on Join, not Login, otherwise player no get heal.
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void playerRejoinGame(PlayerJoinEvent event)
|
||||
{
|
||||
if (!getGame().InProgress() || getGame().QuitOut)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
RejoinPlayerData data = getRejoinPlayerData(player.getName());
|
||||
double health = data.getHealth();
|
||||
|
||||
if (!(health > 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getGame().Manager.runSyncLater(() -> {
|
||||
player.setHealth(health);
|
||||
|
||||
NautHashMap<String, Location> location = getGame().GetLocationStore();
|
||||
|
||||
if (location.containsKey(player.getName()))
|
||||
{
|
||||
player.teleport(location.get(player.getName()));
|
||||
}
|
||||
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void rejoinExpire(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC || getGame().QuitOut)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<RejoinPlayerData> iterator = _data.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
RejoinPlayerData data = iterator.next();
|
||||
GameTeam team = data.getTeam();
|
||||
|
||||
if (!UtilTime.elapsed(data.getTime(), _rejoinTime))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data.getTeam() != null)
|
||||
{
|
||||
getGame().Announce(team.GetColor() + C.Bold + data.getName() + " did not reconnect in time!", false);
|
||||
}
|
||||
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void setRejoinTime(int time)
|
||||
{
|
||||
_rejoinTime = time;
|
||||
}
|
||||
|
||||
public int getRejoinTime()
|
||||
{
|
||||
return _rejoinTime;
|
||||
}
|
||||
|
||||
public void stopPlayerFromRejoining(String name)
|
||||
{
|
||||
Iterator<RejoinPlayerData> iterator = _data.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
RejoinPlayerData data = iterator.next();
|
||||
|
||||
if (data.getName().equals(name))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAllPlayersFromRejoining()
|
||||
{
|
||||
getGame().QuitOut = true;
|
||||
_data.clear();
|
||||
}
|
||||
|
||||
public RejoinPlayerData getRejoinPlayerData(String name)
|
||||
{
|
||||
for (RejoinPlayerData data : _data)
|
||||
{
|
||||
if (data.getName().equals(name))
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<RejoinPlayerData> getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public class RejoinPlayerData
|
||||
{
|
||||
private String _name;
|
||||
private double _health;
|
||||
private Kit _kit;
|
||||
private GameTeam _team;
|
||||
private long _time;
|
||||
|
||||
public RejoinPlayerData(String name, double health, Kit kit, GameTeam team)
|
||||
{
|
||||
_name = name;
|
||||
_health = health;
|
||||
_kit = kit;
|
||||
_team = team;
|
||||
_time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void setHealth(double health)
|
||||
{
|
||||
_health = health;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public double getHealth()
|
||||
{
|
||||
return _health;
|
||||
}
|
||||
|
||||
public Kit getKit()
|
||||
{
|
||||
return _kit;
|
||||
}
|
||||
|
||||
public GameTeam getTeam()
|
||||
{
|
||||
return _team;
|
||||
}
|
||||
|
||||
public long getTime()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,236 @@
|
||||
package nautilus.game.arcade.game.modules;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||
import net.minecraft.server.v1_8_R3.IWorldAccess;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class SafezoneModule extends Module
|
||||
{
|
||||
private Predicate<Location> _isInSafezone = location -> true;
|
||||
|
||||
public SafezoneModule filter(Predicate<Location> predicate)
|
||||
{
|
||||
this._isInSafezone = predicate;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
registerWorldAccess(world);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event)
|
||||
{
|
||||
registerWorldAccess(event.getWorld());
|
||||
}
|
||||
|
||||
private void registerWorldAccess(World world)
|
||||
{
|
||||
IWorldAccess access = new IWorldAccess()
|
||||
{
|
||||
@Override
|
||||
public void a(BlockPosition blockPosition)
|
||||
{
|
||||
Location location = new Location(world, blockPosition.getX(), blockPosition.getY(), blockPosition.getZ());
|
||||
if (isInSafeZone(location))
|
||||
{
|
||||
Block block = location.getBlock();
|
||||
if (block.getType() == Material.COBBLESTONE || block.getType() == Material.OBSIDIAN || block.getType() == Material.STONE)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(BlockPosition blockPosition)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(int i, int i1, int i2, int i3, int i4, int i5)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(String s, double v, double v1, double v2, float v3, float v4)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(EntityHuman entityHuman, String s, double v, double v1, double v2, float v3, float v4)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(int i, boolean b, double v, double v1, double v2, double v3, double v4, double v5, int... ints)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Entity entity)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(Entity entity)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(String s, BlockPosition blockPosition)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(int i, BlockPosition blockPosition, int i1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(EntityHuman entityHuman, int i, BlockPosition blockPosition, int i1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(int i, BlockPosition blockPosition, int i1)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// ((CraftWorld) world).getHandle().u.add(access);
|
||||
}
|
||||
|
||||
// fixme flowing water and stuff
|
||||
|
||||
@EventHandler
|
||||
public void preventBlockPlacement(BlockPlaceEvent event)
|
||||
{
|
||||
if (isInSafeZone(event.getBlock().getLocation()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build in this area!"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventStructureGrow(StructureGrowEvent event)
|
||||
{
|
||||
Iterator<BlockState> blocks = event.getBlocks().iterator();
|
||||
while (blocks.hasNext())
|
||||
{
|
||||
BlockState next = blocks.next();
|
||||
if (isInSafeZone(next.getLocation()))
|
||||
{
|
||||
blocks.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventBlockGrow(BlockGrowEvent event)
|
||||
{
|
||||
if (isInSafeZone(event.getBlock().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventBoneMeal(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
boolean isIllegal = false;
|
||||
if (!isIllegal)
|
||||
{
|
||||
isIllegal = event.getPlayer().getItemInHand().getType() == Material.INK_SACK &&
|
||||
event.getPlayer().getItemInHand().getData().getData() == (byte) 15;
|
||||
}
|
||||
|
||||
if (isIllegal && isInSafeZone(event.getClickedBlock().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventPistons(BlockPistonExtendEvent event)
|
||||
{
|
||||
boolean willBeUnsafe = false;
|
||||
for (Block block : event.getBlocks())
|
||||
{
|
||||
if (isInSafeZone(block.getRelative(event.getDirection()).getLocation()))
|
||||
{
|
||||
willBeUnsafe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (willBeUnsafe)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventPistons(BlockPistonRetractEvent event)
|
||||
{
|
||||
boolean willBeUnsafe = false;
|
||||
for (Block block : event.getBlocks())
|
||||
{
|
||||
if (isInSafeZone(block.getLocation()))
|
||||
{
|
||||
willBeUnsafe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (willBeUnsafe)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInSafeZone(Location location)
|
||||
{
|
||||
return _isInSafezone.test(location);
|
||||
}
|
||||
}
|
@ -21,17 +21,10 @@ public class VersionModule extends Module
|
||||
{
|
||||
|
||||
private MinecraftVersion _minecraftVersion;
|
||||
private String _kickMessage;
|
||||
|
||||
|
||||
public VersionModule(MinecraftVersion minecraftVersion)
|
||||
{
|
||||
this(minecraftVersion, "You have an outdated client for this game!");
|
||||
}
|
||||
|
||||
public VersionModule(MinecraftVersion minecraftVersion, String kickMessage)
|
||||
{
|
||||
_minecraftVersion = minecraftVersion;
|
||||
_kickMessage = kickMessage;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
|
@ -1,19 +1,14 @@
|
||||
package nautilus.game.arcade.game.modules.combatlog;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilParser;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.modules.Module;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -26,40 +21,51 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilParser;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
/*
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.modules.Module;
|
||||
import nautilus.game.arcade.game.modules.RejoinModule;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassEntry;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
|
||||
/**
|
||||
* This module will spawn combat log NPCs for players who disconnect
|
||||
*/
|
||||
public class CombatLogModule extends Module
|
||||
{
|
||||
// The map of player UUIDs to their combat log NPCs
|
||||
/**
|
||||
* Map of UUIDs of players who are now offline, to their CombatLogNPCs
|
||||
*/
|
||||
private Map<UUID, CombatLogNPC> _logoutNpcs = new HashMap<>();
|
||||
|
||||
// The map of player UUIDs and who killed their combat logged NPC
|
||||
/**
|
||||
* Map of UUIDs of players who are now offline, and who killed them
|
||||
*/
|
||||
private Map<UUID, String> _killedBy = new HashMap<>();
|
||||
|
||||
// The time that combat log npcs will stay spawned for, in milliseconds
|
||||
/**
|
||||
* How long combat log NPCs will stay spawned in for, measured in milliseconds
|
||||
*/
|
||||
private int _spawnTime = 60000;
|
||||
// Whether to notify the combat logged player on join if they have been killed
|
||||
|
||||
/**
|
||||
* Whether to notify the combat logged player on join if they have been killed
|
||||
*/
|
||||
private boolean _notifyPlayer = true;
|
||||
// Whether to spawn a combat log NPC for creative players
|
||||
private boolean _spawnForCreative = true;
|
||||
// The action to take once a combat logged NPC has died
|
||||
private Consumer<CombatLogNPC> _onKill = npc ->
|
||||
{
|
||||
|
||||
};
|
||||
// The action to take once a combat logged NPC has expired
|
||||
private Consumer<CombatLogNPC> _onExpire = npc ->
|
||||
{
|
||||
|
||||
};
|
||||
/**
|
||||
* Whether to integrate with {@link CompassModule}
|
||||
*/
|
||||
private boolean _integrateWithCompassModule = true;
|
||||
|
||||
private int _locationTaskId = -1;
|
||||
|
||||
@ -72,6 +78,39 @@ public class CombatLogModule extends Module
|
||||
getGame().GetLocationStore().put(npc.getPlayerInfo().getName(), npc.getNPC().getLocation());
|
||||
}
|
||||
}, 0L, 1L).getTaskId();
|
||||
|
||||
if (this._integrateWithCompassModule)
|
||||
{
|
||||
CompassModule compassModule = getGame().getModule(CompassModule.class);
|
||||
if (compassModule != null)
|
||||
{
|
||||
compassModule.addSupplier(() ->
|
||||
getAllNPCs()
|
||||
.stream()
|
||||
.filter(ent ->
|
||||
{
|
||||
if (ent.getNPC() == null)
|
||||
{
|
||||
System.out.println("Null npc entity? " + ent.getPlayerInfo().getName() + " " + ent.getPlayerInfo().getUniqueId());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.map(npc -> new CompassEntry(npc.getNPC(), npc.getPlayerInfo().getName(), npc.getPlayerInfo().getName() + " (Disconnected)", npc.getPlayerInfo().getTeam(), npc.getPlayerInfo().getKit()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilServer.raiseError(new RuntimeException("CompassModule was null but integration was not disabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CombatLogModule disableCompassModuleIntegration()
|
||||
{
|
||||
this._integrateWithCompassModule = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CombatLogModule setNotifyPlayer(boolean notifyPlayer)
|
||||
@ -80,44 +119,121 @@ public class CombatLogModule extends Module
|
||||
return this;
|
||||
}
|
||||
|
||||
public CombatLogModule setSpawnForCreative(boolean spawnForCreative)
|
||||
{
|
||||
this._spawnForCreative = spawnForCreative;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CombatLogModule setOnDeathAction(Consumer<CombatLogNPC> action)
|
||||
{
|
||||
this._onKill = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CombatLogModule setOnExpireAction(Consumer<CombatLogNPC> action)
|
||||
{
|
||||
this._onExpire = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CombatLogModule setCombatLogTime(int time)
|
||||
{
|
||||
this._spawnTime = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Spawns a combat log NPC for the given player if that player does not already have one
|
||||
*/
|
||||
public void spawnLogoutNpc(Player player)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void on(PlayerQuitEvent event)
|
||||
{
|
||||
if (hasLogoutNpc(player))
|
||||
return;
|
||||
if (player.getGameMode() == GameMode.CREATIVE && !_spawnForCreative)
|
||||
Player player = event.getPlayer();
|
||||
if (getGame().InProgress() && getGame().IsAlive(player))
|
||||
{
|
||||
if (hasLogoutNpc(player))
|
||||
return;
|
||||
|
||||
CombatLogNPCPreSpawnEvent preSpawnEvent = new CombatLogNPCPreSpawnEvent(player);
|
||||
UtilServer.CallEvent(preSpawnEvent);
|
||||
if (preSpawnEvent.isCancelled())
|
||||
return;
|
||||
|
||||
CombatLogNPC npc = new CombatLogNPC(this, player);
|
||||
_logoutNpcs.put(player.getUniqueId(), npc);
|
||||
System.out.println(String.format("Spawned combat log NPC for %s!", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (hasLogoutNpc(event.getPlayer()))
|
||||
{
|
||||
despawnLogoutNpc(event.getPlayer());
|
||||
}
|
||||
|
||||
if (_killedBy.containsKey(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
String name = _killedBy.remove(event.getPlayer().getUniqueId());
|
||||
if (_notifyPlayer && name != null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Combat Log", "While you were gone, you were killed by " + ChatColor.GREEN + name + C.mBody + "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
|
||||
|
||||
if (logoutNpc == null)
|
||||
return;
|
||||
|
||||
CombatLogNPC npc = new CombatLogNPC(this, player, getGame().getArcadeManager());
|
||||
npc.spawn();
|
||||
_logoutNpcs.put(player.getUniqueId(), npc);
|
||||
System.out.println(String.format("Spawned combat log NPC for %s!", player.getName()));
|
||||
CombatLogNPCKilledEvent npcKilledEvent = new CombatLogNPCKilledEvent(logoutNpc);
|
||||
UtilServer.CallEvent(npcKilledEvent);
|
||||
|
||||
logoutNpc.despawn();
|
||||
_logoutNpcs.remove(logoutNpc.getPlayerInfo().getUniqueId());
|
||||
|
||||
event.getDrops().clear(); // Clear the entity's item drops. If drops are wanted they should be dropped in the event
|
||||
|
||||
if (logoutNpc.getLastDamager() != null)
|
||||
{
|
||||
_killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), logoutNpc.getLastDamager().getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
_killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), UtilParser.parseDamageCause(logoutNpc.getLastDamageCause()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDamaged(EntityDamageEvent event)
|
||||
{
|
||||
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
|
||||
|
||||
if (logoutNpc == null)
|
||||
return;
|
||||
|
||||
LivingEntity damager = UtilEvent.GetDamagerEntity(event, true);
|
||||
|
||||
Player damagerPlayer = null;
|
||||
if (damager instanceof Player)
|
||||
{
|
||||
damagerPlayer = (Player) damager;
|
||||
}
|
||||
|
||||
if (getGame() instanceof TeamGame && damagerPlayer != null)
|
||||
{
|
||||
GameTeam damagerTeam = getGame().GetTeam(damagerPlayer);
|
||||
if (damagerTeam == logoutNpc.getPlayerInfo().getTeam())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void recordDamage(EntityDamageEvent event)
|
||||
{
|
||||
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
|
||||
|
||||
if (logoutNpc == null)
|
||||
return;
|
||||
|
||||
logoutNpc.getNPC().getWorld().playSound(logoutNpc.getNPC().getLocation(), Sound.HURT_FLESH, 1, 1);
|
||||
logoutNpc.recordDamage(event);
|
||||
|
||||
getGame().getArcadeManager().runSync(() ->
|
||||
{
|
||||
CombatLogNPC npc = getLogoutNpc(event.getEntity());
|
||||
if (npc != null)
|
||||
{
|
||||
getGame().getModule(RejoinModule.class).getRejoinPlayerData(npc.getPlayerInfo().getName()).setHealth(npc.getNPC().getHealth());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean hasLogoutNpc(Player player)
|
||||
@ -142,42 +258,12 @@ public class CombatLogModule extends Module
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void on(PlayerQuitEvent event)
|
||||
{
|
||||
if (getGame().InProgress() && getGame().IsAlive(event.getPlayer()))
|
||||
{
|
||||
spawnLogoutNpc(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerJoinEvent event)
|
||||
{
|
||||
if (hasLogoutNpc(event.getPlayer()))
|
||||
{
|
||||
despawnLogoutNpc(event.getPlayer());
|
||||
}
|
||||
|
||||
if (_killedBy.containsKey(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
String name = _killedBy.remove(event.getPlayer().getUniqueId());
|
||||
if (_notifyPlayer && name != null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Combat Log", "While you were gone, you were killed by " + ChatColor.GREEN + name + C.mBody + "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
System.out.println("Killing combat log NPCs");
|
||||
|
||||
for (CombatLogNPC npc : _logoutNpcs.values())
|
||||
{
|
||||
npc.despawn();
|
||||
}
|
||||
_logoutNpcs.values().forEach(CombatLogNPC::despawn);
|
||||
|
||||
_logoutNpcs.clear();
|
||||
_killedBy.clear();
|
||||
@ -198,79 +284,6 @@ public class CombatLogModule extends Module
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
|
||||
|
||||
if (logoutNpc == null)
|
||||
return;
|
||||
|
||||
_onKill.accept(logoutNpc);
|
||||
logoutNpc.onDeath();
|
||||
event.getDrops().clear(); // Clear the entity's item drops. If drops are wanted they can be added
|
||||
|
||||
if (logoutNpc.getLastDamager() != null)
|
||||
{
|
||||
_killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), logoutNpc.getLastDamager().getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
_killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), UtilParser.parseDamageCause(logoutNpc.getLastDamageCause()));
|
||||
}
|
||||
|
||||
|
||||
if (getGame() instanceof TeamGame)
|
||||
{
|
||||
TeamGame teamGame = (TeamGame) getGame();
|
||||
teamGame.RejoinTimes.remove(logoutNpc.getPlayerInfo().getName());
|
||||
teamGame.RejoinKit.remove(logoutNpc.getPlayerInfo().getName());
|
||||
teamGame.RejoinTeam.remove(logoutNpc.getPlayerInfo().getName());
|
||||
teamGame.RejoinHealth.remove(logoutNpc.getPlayerInfo().getName());
|
||||
}
|
||||
|
||||
_logoutNpcs.remove(logoutNpc.getPlayerInfo().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDamaged(EntityDamageEvent event)
|
||||
{
|
||||
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
|
||||
|
||||
if (logoutNpc != null)
|
||||
{
|
||||
LivingEntity damager = UtilEvent.GetDamagerEntity(event, true);
|
||||
|
||||
Player damagerPlayer = null;
|
||||
if (damager instanceof Player)
|
||||
{
|
||||
damagerPlayer = (Player) damager;
|
||||
}
|
||||
|
||||
if (getGame() instanceof TeamGame && damagerPlayer != null)
|
||||
{
|
||||
GameTeam damagerTeam = getGame().GetTeam(damagerPlayer);
|
||||
if (damagerTeam == logoutNpc.getPlayerInfo().getTeam())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
logoutNpc.getNPC().getWorld().playSound(logoutNpc.getNPC().getLocation(), Sound.HURT_FLESH, 1, 1);
|
||||
|
||||
if (getGame() instanceof TeamGame)
|
||||
{
|
||||
getGame().getArcadeManager().runSync(() ->
|
||||
{
|
||||
((TeamGame) getGame()).RejoinHealth.put(logoutNpc.getPlayerInfo().getName(), logoutNpc.getNPC().getHealth());
|
||||
});
|
||||
}
|
||||
|
||||
logoutNpc.handleDamageEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
@ -287,24 +300,45 @@ public class CombatLogModule extends Module
|
||||
{
|
||||
CombatLogNPC npc = iterator.next();
|
||||
|
||||
if (Bukkit.getPlayerExact(npc.getPlayerInfo().getName()) != null)
|
||||
if (npc.getNPC() == null)
|
||||
{
|
||||
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 1");
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
try
|
||||
{
|
||||
new IllegalArgumentException("Strange, the NPC with data " + npc.getPlayerInfo().getName() + " " + npc.getPlayerInfo().getUniqueId() + " was null").printStackTrace();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
else if (!npc.isAlive())
|
||||
else
|
||||
{
|
||||
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 2");
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
}
|
||||
else if (npc.getAliveDuation() > this._spawnTime)
|
||||
{
|
||||
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 3");
|
||||
_onExpire.accept(npc);
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
if (Bukkit.getPlayerExact(npc.getPlayerInfo().getName()) != null)
|
||||
{
|
||||
// Should never happen
|
||||
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 1");
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
}
|
||||
else if (!npc.isAlive())
|
||||
{
|
||||
// Should never happen
|
||||
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 2");
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
}
|
||||
else if (npc.getAliveDuation() > this._spawnTime)
|
||||
{
|
||||
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 3");
|
||||
CombatLogNPCExpiredEvent expiredEvent = new CombatLogNPCExpiredEvent(npc);
|
||||
UtilServer.CallEvent(expiredEvent);
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,19 @@
|
||||
package nautilus.game.arcade.game.modules.combatlog;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityCreeper;
|
||||
import net.minecraft.server.v1_8_R3.EntitySkeleton;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Creeper;
|
||||
@ -21,8 +27,6 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class CombatLogNPC
|
||||
{
|
||||
private CombatLogModule _module;
|
||||
|
||||
private PlayerInfo _playerInfo;
|
||||
|
||||
private Hologram _hologram;
|
||||
@ -39,29 +43,21 @@ public class CombatLogNPC
|
||||
private EntityDamageEvent.DamageCause _lastDamageCause;
|
||||
private Entity _lastDamager;
|
||||
|
||||
public CombatLogNPC(CombatLogModule module, Player player, ArcadeManager arcadeManager)
|
||||
CombatLogNPC(CombatLogModule module, Player player)
|
||||
{
|
||||
this._module = module;
|
||||
ArcadeManager arcadeManager = module.getGame().getArcadeManager();
|
||||
|
||||
_playerInfo = new PlayerInfo(player, arcadeManager);
|
||||
|
||||
_endingTime = System.currentTimeMillis() + this._module.getSpawnTime();
|
||||
|
||||
_disguiseManager = arcadeManager.GetDisguise();
|
||||
|
||||
_spawnDate = System.currentTimeMillis();
|
||||
_endingTime = System.currentTimeMillis() + module.getSpawnTime();
|
||||
|
||||
_hologram = new Hologram(arcadeManager.getHologramManager(), player.getEyeLocation().add(0, 1, 0), "Quitting in " + UtilTime.MakeStr(Math.max(_endingTime - System.currentTimeMillis(), 0)));
|
||||
_spawnDate = 0;
|
||||
_spawnHealth = player.getHealth();
|
||||
_maxHealth = player.getMaxHealth();
|
||||
_hologram.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the {@code _npc} associated with this CombatLogNPC is killed
|
||||
* and thus drops all the owner's items.
|
||||
*/
|
||||
public void onDeath()
|
||||
{
|
||||
despawn();
|
||||
_npc = spawnNpc(player);
|
||||
}
|
||||
|
||||
public void update()
|
||||
@ -91,14 +87,6 @@ public class CombatLogNPC
|
||||
return System.currentTimeMillis() - _spawnDate;
|
||||
}
|
||||
|
||||
public void spawn()
|
||||
{
|
||||
if (_npc != null) despawn();
|
||||
|
||||
_npc = spawnNpc(getPlayer());
|
||||
_spawnDate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void despawn()
|
||||
{
|
||||
if (_disguise != null)
|
||||
@ -130,15 +118,27 @@ public class CombatLogNPC
|
||||
return _playerInfo;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
public LivingEntity getNPC()
|
||||
{
|
||||
return _playerInfo.getPlayer();
|
||||
return this._npc;
|
||||
}
|
||||
|
||||
public EntityDamageEvent.DamageCause getLastDamageCause()
|
||||
{
|
||||
return _lastDamageCause;
|
||||
}
|
||||
|
||||
public Entity getLastDamager()
|
||||
{
|
||||
return _lastDamager;
|
||||
}
|
||||
|
||||
private LivingEntity spawnNpc(Player player)
|
||||
{
|
||||
Location spawnLoc = player.getLocation();
|
||||
LivingEntity skel = player.getWorld().spawn(spawnLoc, Creeper.class);
|
||||
EntityCreeper entityCreeper = new EntityCreeper(((CraftWorld) spawnLoc.getWorld()).getHandle());
|
||||
LivingEntity skel = (LivingEntity) entityCreeper.getBukkitEntity();
|
||||
skel.teleport(spawnLoc);
|
||||
skel.setRemoveWhenFarAway(false);
|
||||
skel.setMetadata("CombatLogNPC", new FixedMetadataValue(_disguiseManager.getPlugin(), player.getUniqueId().toString()));
|
||||
skel.teleport(spawnLoc);
|
||||
@ -165,17 +165,7 @@ public class CombatLogNPC
|
||||
return skel;
|
||||
}
|
||||
|
||||
public Entity getLastDamager()
|
||||
{
|
||||
return _lastDamager;
|
||||
}
|
||||
|
||||
public LivingEntity getNPC()
|
||||
{
|
||||
return this._npc;
|
||||
}
|
||||
|
||||
public void handleDamageEvent(EntityDamageEvent event)
|
||||
void recordDamage(EntityDamageEvent event)
|
||||
{
|
||||
this._lastDamageCause = event.getCause();
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
@ -188,9 +178,4 @@ public class CombatLogNPC
|
||||
this._lastDamager = null;
|
||||
}
|
||||
}
|
||||
|
||||
public EntityDamageEvent.DamageCause getLastDamageCause()
|
||||
{
|
||||
return _lastDamageCause;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package nautilus.game.arcade.game.modules.combatlog;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class CombatLogNPCExpiredEvent extends Event
|
||||
{
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final CombatLogNPC _npc;
|
||||
|
||||
public CombatLogNPCExpiredEvent(CombatLogNPC npc)
|
||||
{
|
||||
_npc = npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public CombatLogNPC getNpc()
|
||||
{
|
||||
return _npc;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package nautilus.game.arcade.game.modules.combatlog;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class CombatLogNPCKilledEvent extends Event
|
||||
{
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final CombatLogNPC _npc;
|
||||
|
||||
public CombatLogNPCKilledEvent(CombatLogNPC npc)
|
||||
{
|
||||
_npc = npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public CombatLogNPC getNpc()
|
||||
{
|
||||
return _npc;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package nautilus.game.arcade.game.modules.combatlog;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class CombatLogNPCPreSpawnEvent extends Event implements Cancellable
|
||||
{
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player _player;
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public CombatLogNPCPreSpawnEvent(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b)
|
||||
{
|
||||
_cancelled = b;
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ package nautilus.game.arcade.game.modules.combatlog;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -24,8 +26,9 @@ public class PlayerInfo
|
||||
private List<ItemStack> _items;
|
||||
private ChatColor _teamColor = ChatColor.GRAY;
|
||||
private GameTeam _team;
|
||||
private Kit _kit;
|
||||
|
||||
public PlayerInfo(Player player, ArcadeManager arcadeManager)
|
||||
PlayerInfo(Player player, ArcadeManager arcadeManager)
|
||||
{
|
||||
_playerName = player.getName();
|
||||
_playerUuid = player.getUniqueId();
|
||||
@ -35,6 +38,7 @@ public class PlayerInfo
|
||||
{
|
||||
_teamColor = _team.GetColor();
|
||||
}
|
||||
_kit = arcadeManager.GetGame().GetKit(player);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@ -47,11 +51,6 @@ public class PlayerInfo
|
||||
return _playerUuid;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return Bukkit.getPlayerExact(_playerName);
|
||||
}
|
||||
|
||||
public ChatColor getTeamColor()
|
||||
{
|
||||
return _teamColor;
|
||||
@ -66,4 +65,9 @@ public class PlayerInfo
|
||||
{
|
||||
return this._items;
|
||||
}
|
||||
|
||||
public Kit getKit()
|
||||
{
|
||||
return this._kit;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.addons.compass;
|
||||
package nautilus.game.arcade.game.modules.compass;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -9,26 +10,26 @@ public class CompassAttemptTargetEvent extends PlayerEvent implements Cancellabl
|
||||
{
|
||||
private static HandlerList _handlers = new HandlerList();
|
||||
private boolean _cancelled = false;
|
||||
|
||||
private Player _target;
|
||||
|
||||
public CompassAttemptTargetEvent(Player player, Player target)
|
||||
|
||||
private Entity _target;
|
||||
|
||||
CompassAttemptTargetEvent(Player player, Entity target)
|
||||
{
|
||||
super(player);
|
||||
|
||||
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Player getTarget()
|
||||
|
||||
public Entity getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
@ -0,0 +1,49 @@
|
||||
package nautilus.game.arcade.game.modules.compass;
|
||||
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class CompassEntry
|
||||
{
|
||||
private Entity _entity;
|
||||
private String _name;
|
||||
private String _displayName;
|
||||
private GameTeam _team;
|
||||
private Kit _kit;
|
||||
|
||||
public CompassEntry(Entity entity, String name, String displayName, GameTeam team, Kit kit)
|
||||
{
|
||||
_entity = entity;
|
||||
_name = name;
|
||||
_displayName = displayName;
|
||||
_team = team;
|
||||
_kit = kit;
|
||||
}
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
return _entity;
|
||||
}
|
||||
|
||||
public GameTeam getTeam()
|
||||
{
|
||||
return _team;
|
||||
}
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
return _displayName;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public Kit getKit()
|
||||
{
|
||||
return _kit;
|
||||
}
|
||||
}
|
@ -0,0 +1,237 @@
|
||||
package nautilus.game.arcade.game.modules.compass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.modules.Module;
|
||||
import nautilus.game.arcade.game.modules.compass.menu.CompassMenu;
|
||||
|
||||
public class CompassModule extends Module
|
||||
{
|
||||
private static final ItemStack COMPASS_ITEM =
|
||||
new ItemBuilder(Material.COMPASS)
|
||||
.setAmount(1)
|
||||
.setTitle(C.cGreen + C.Bold + "Tracking Compass")
|
||||
.build();
|
||||
|
||||
private List<Supplier<Collection<CompassEntry>>> _suppliers = new ArrayList<>();
|
||||
|
||||
private CompassMenu _compassMenu;
|
||||
private boolean _giveCompassItem = true;
|
||||
private boolean _giveCompassItemToSpectators = true;
|
||||
|
||||
public CompassModule addSupplier(Supplier<Collection<CompassEntry>> supplier)
|
||||
{
|
||||
_suppliers.add(supplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CompassModule setGiveCompass(boolean b)
|
||||
{
|
||||
_giveCompassItem = b;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CompassModule setGiveCompassToSpecs(boolean b)
|
||||
{
|
||||
_giveCompassItemToSpectators = b;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
HandlerList.unregisterAll(_compassMenu);
|
||||
_compassMenu = null;
|
||||
_suppliers = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup()
|
||||
{
|
||||
_compassMenu = new CompassMenu(this);
|
||||
_suppliers.add(() ->
|
||||
getGame()
|
||||
.GetPlayers(true)
|
||||
.stream()
|
||||
.map(player -> new CompassEntry(player, player.getName(), player.getName(), getGame().GetTeam(player), getGame().GetKit(player)))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
GameTeam team = getGame().GetTeam(player);
|
||||
|
||||
stream()
|
||||
.filter(entry -> entry.getEntity() != player)
|
||||
.filter(entry -> getGame().GetTeamList().size() <= 1 || team == null || !team.equals(entry.getTeam()))
|
||||
.filter(entry -> !UtilServer.CallEvent(new CompassAttemptTargetEvent(player, entry.getEntity())).isCancelled())
|
||||
.min((a, b) -> Double.compare(UtilMath.offset(player, a.getEntity()), UtilMath.offset(player, b.getEntity())))
|
||||
.ifPresent(target ->
|
||||
{
|
||||
Entity targetEntity = target.getEntity();
|
||||
GameTeam targetTeam = target.getTeam();
|
||||
|
||||
if (_giveCompassItem || (_giveCompassItemToSpectators && getGame().getArcadeManager().isSpectator(player)))
|
||||
{
|
||||
long count = UtilInv.getItems(player, true, true, true)
|
||||
.stream()
|
||||
.filter(this::isCompassItem)
|
||||
.count();
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
player.getInventory().addItem(COMPASS_ITEM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.setCompassTarget(targetEntity.getLocation());
|
||||
|
||||
double heightDiff = targetEntity.getLocation().getY() - player.getLocation().getY();
|
||||
|
||||
//Action Bar
|
||||
if (isCompassItem(player.getItemInHand()))
|
||||
{
|
||||
UtilTextBottom.display(
|
||||
" " + C.cWhite + C.Bold + "Nearest Target: " + targetTeam.GetColor() + target.getDisplayName() +
|
||||
" " + C.cWhite + C.Bold + "Distance: " + targetTeam.GetColor() + UtilMath.trim(1, UtilMath.offset(player, targetEntity)) +
|
||||
" " + C.cWhite + C.Bold + "Height: " + targetTeam.GetColor() + UtilMath.trim(1, heightDiff), player
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent event)
|
||||
{
|
||||
if (!isCompassItem(event.getItemDrop().getItemStack()))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot drop " + F.item("Target Compass") + "."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void DeathRemove(PlayerDeathEvent event)
|
||||
{
|
||||
for (Iterator<ItemStack> it = event.getDrops().iterator(); it.hasNext(); )
|
||||
{
|
||||
ItemStack item = it.next();
|
||||
if (isCompassItem(item))
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void SpectatorTeleport(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getAction() == Action.PHYSICAL)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (getGame().IsAlive(player))
|
||||
return;
|
||||
|
||||
if (!isCompassItem(player.getItemInHand()))
|
||||
return;
|
||||
|
||||
if (player.getGameMode() == GameMode.SPECTATOR)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
if (!Recharge.Instance.use(player, "Spectate", 3000, true, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spectateNearestPlayer(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_compassMenu.attemptShopOpen(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void spectateNearestPlayer(Player spectator)
|
||||
{
|
||||
stream()
|
||||
.min((a, b) -> Double.compare(UtilMath.offset(spectator, a.getEntity()), UtilMath.offset(spectator, b.getEntity())))
|
||||
.map(CompassEntry::getEntity)
|
||||
.ifPresent(target -> spectator.teleport(target.getLocation().add(0, 1, 0)));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void closeShop(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState().equals(Game.GameState.End))
|
||||
{
|
||||
UtilServer.getPlayersCollection().stream().filter(_compassMenu::isPlayerInShop).forEach(Player::closeInventory);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateShop(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
_compassMenu.update();
|
||||
}
|
||||
|
||||
public Stream<CompassEntry> stream()
|
||||
{
|
||||
return _suppliers.stream().map(Supplier::get).flatMap(Collection::stream);
|
||||
}
|
||||
|
||||
// Defined here to make modifying definitions easier
|
||||
public boolean isCompassItem(ItemStack item)
|
||||
{
|
||||
return UtilItem.isSimilar(COMPASS_ITEM, item, UtilItem.ItemAttribute.NAME, UtilItem.ItemAttribute.MATERIAL);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package nautilus.game.arcade.game.modules.compass.menu;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.game.modules.compass.menu.page.CompassPage;
|
||||
|
||||
public class CompassMenu extends ShopBase<ArcadeManager>
|
||||
{
|
||||
private CompassModule _compassModule;
|
||||
|
||||
public CompassMenu(CompassModule module)
|
||||
{
|
||||
super(module.getGame().getArcadeManager(), module.getGame().getArcadeManager().GetClients(), module.getGame().getArcadeManager().GetDonation(), "Spectate Menu");
|
||||
this._compassModule = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<ArcadeManager, ? extends ShopBase<ArcadeManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return new CompassPage(this, _compassModule, player);
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
for (ShopPageBase<ArcadeManager, ? extends ShopBase<ArcadeManager>> shopPage : getPlayerPageMap().values())
|
||||
{
|
||||
shopPage.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user