Merge remote-tracking branch 'origin/develop' into develop

* origin/develop: (37 commits)
  Implement new sales announcement system in Lobbies and ClansHubs, and remove old Unranked Player Manager
  Fix SkyWarrior Kit
  Undo my report changes
  Set up support server with Thankful Chest tracking and Eternal Rank
  Add Cake Mount and implement it in Thankful Chest
  Use getName() instead of a String
  Enable MountChicken with some small modifications and add it to Thankful Chest
  Implement Thankful chest, patch Trick or Treat chest showing as purchasable, make SubscriptionDuration enum public and static, and create a Power Play Reward
  Remove MCL and OITQP from the stats page
  Take a second crack at fixing invisibility across Arcade and Clans
  Properly block placement of redstone-based blocks in Clans
  Fix Clans servers not restarting every night, display an uptime notification whenever Clans servers shut down for any reason, and remove unnecessary onDisables from the main ClansManager onDisable
  Patch Frozen players in clans spawning CombatLog NPCs when leaving, patch ClansCommandExecutedEvent not always being called, clean up ClanBanner code, and make Freeze System and Nether Manager effectively block Clans Commands (particularly teleportation)
  Fix game scoreboards breaking when given more than 15 lines and removed OITQ Payload from the server selection compass GUI
  Patch Items with type FEATHER, BONE, or RAW_CHICKEN being automatically instantly removed, patch Carl the Creeper not viewing playwire as an available reward to inform players about, and patch Carl the Creeper not informing players of available rewards on Clans Hubs and Lobbies not included in the main server group
  Fix HolidayManager being outdated
  Update Enderchest endpoint location
  Setup enderchest API
  QA changes
  More bugs
  ...
This commit is contained in:
Shaun Bennett 2016-11-24 00:51:46 -05:00
commit 192273314f
186 changed files with 7684 additions and 4222 deletions

View File

@ -0,0 +1,5 @@
package mineplex.core.common.api;
public class ApiException extends Exception
{
}

View File

@ -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;

View File

@ -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();

View File

@ -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");
}
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -1,4 +1,4 @@
package mineplex.core.timing;
package mineplex.core.common.timing;
public class TimeData
{

View File

@ -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)

View File

@ -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);
}
}

View File

@ -6,6 +6,8 @@ public class UtilParser
{
public static String parseDamageCause(EntityDamageEvent.DamageCause cause)
{
if (cause == null)
return "Unknown";
switch (cause)
{
case CONTACT:

View File

@ -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);
}
}
}

View File

@ -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);

View File

@ -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;

View File

@ -172,7 +172,7 @@ public enum Achievement
AchievementCategory.UHC),
//MC League
MC_LEAGUE_STRIKE("First Strike", 600,
/*MC_LEAGUE_STRIKE("First Strike", 600,
new String[] {"MC League.FirstStrike"},
new String[] {"Earn 30 First Bloods"},
new int[] {30},
@ -206,7 +206,7 @@ public enum Achievement
new String[] {"MC League.SavingUp"},
new String[] {"Craft a Diamond Chestplate"},
new int[] {1},
AchievementCategory.MC_LEAGUE),
AchievementCategory.MC_LEAGUE),*/
//UHC
WIZARDS_WINS("Supreme Wizard", 600,
@ -1006,7 +1006,7 @@ public enum Achievement
AchievementCategory.SPEED_BUILDERS),
// OITQP
QUIVER_PAYLOAD_BLOSSOM("Flowering Blossom", 2000,
/*QUIVER_PAYLOAD_BLOSSOM("Flowering Blossom", 2000,
new String[]{"One in the Quiver Payload.Blossom"},
new String[]{"Get 4 kills with a single Pyromancer ultimate."},
new int[]{1},
@ -1034,7 +1034,7 @@ public enum Achievement
new String[]{"One in the Quiver Payload.Bow"},
new String[]{"Get 10 kills in a single game without firing an arrow."},
new int[]{1},
AchievementCategory.ONE_IN_THE_QUIVER_PAYLOAD),
AchievementCategory.ONE_IN_THE_QUIVER_PAYLOAD),*/
// Skyfall
SKYFALL_GAMES_WINS("Skyfaller", 600,

View File

@ -47,11 +47,23 @@ 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()),
MC_LEAGUE("MC League", null,
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.IRON_CHESTPLATE, 0, GameCategory.SURVIVAL, "None", true, GameDisplay.Minecraft_League.getGameId()),
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()),*/
WIZARDS("Wizards", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
@ -171,9 +183,9 @@ public enum AchievementCategory
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")},
Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null, false, GameDisplay.SpeedBuilders.getGameId()),
ONE_IN_THE_QUIVER_PAYLOAD("One in the Quiver Payload", null,
/*ONE_IN_THE_QUIVER_PAYLOAD("One in the Quiver Payload", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED},
Material.EXPLOSIVE_MINECART, 0, GameCategory.CLASSICS, "Sky Warrior Kit", false, GameDisplay.QuiverPayload.getGameId()),
Material.EXPLOSIVE_MINECART, 0, GameCategory.CLASSICS, "Sky Warrior Kit", false, GameDisplay.QuiverPayload.getGameId()),*/
SKYFALL("Skyfall", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, null, new StatDisplay("Booster Rings", "Rings"),
@ -335,6 +347,6 @@ public enum AchievementCategory
public enum GameCategory
{
GLOBAL, HOLIDAY, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE
GLOBAL, HOLIDAY, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE, UHC
}
}

View File

@ -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);
}
}

View File

@ -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)
{

View File

@ -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);
}
});
}
}

View File

@ -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);

View File

@ -525,7 +525,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
data.setIlluminatedChests(2);
data.setMythicalChests(2);
data.setOmegaChests(1);
} else if (rank.has(Rank.TITAN))
}
else if (rank.has(Rank.TITAN))
{
data.setMythicalChests(5);
}
@ -697,7 +698,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
int availableRewards = 0;
if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() == -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++;
if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++;
if (_youtubeManager.canYoutube(player)) availableRewards++;
if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++;
if (canDaily(player)) availableRewards++;
@ -858,11 +859,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
{
if(_pollManager.hasPoll(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() == -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
if (_pollManager.hasPoll(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
{
if(_showCarl.containsKey(player.getName()))
if (_showCarl.containsKey(player.getName()))
{
if(_plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Lobby"))
if (_plugin.getClass().getSimpleName().equalsIgnoreCase("Hub") || _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub"))
UtilPlayer.message(player, C.cDGreen + C.Bold + "Carl the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!");
}
}

View File

@ -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()
{

View File

@ -46,7 +46,7 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
addMount(mount, slot);
slot++;
if (slot == 17)
if (slot == 17 || slot == 26)
slot += 2;
}
@ -108,6 +108,11 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Haunted Chests");
}
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -15)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Thankful Treasure");
}
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -14)
{
itemLore.add(C.cBlack);

View File

@ -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);
}
}

View File

@ -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!"));
}
}

View File

@ -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;
}
}

View File

@ -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),

View File

@ -24,7 +24,9 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.mount.types.MountBabyReindeer;
import mineplex.core.mount.types.MountCake;
import mineplex.core.mount.types.MountCart;
import mineplex.core.mount.types.MountChicken;
import mineplex.core.mount.types.MountDragon;
import mineplex.core.mount.types.MountFreedomHorse;
import mineplex.core.mount.types.MountFrost;
@ -77,7 +79,8 @@ public class MountManager extends MiniPlugin
_types.add(new MountFreedomHorse(this));
_types.add(new MountNightmareSteed(this));
// Hidden in this update
//_types.add(new MountChicken(this));
_types.add(new MountChicken(this));
_types.add(new MountCake(this));
//_types.add(new MountSheep(this));
}

View File

@ -0,0 +1,133 @@
package mineplex.core.mount.types;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
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.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilVariant;
public class MountCake extends HorseMount
{
public MountCake(MountManager manager)
{
super(manager, "Cake Mount",
UtilText.splitLineToArray(C.cGray + "The Lie.", LineFormat.LORE),
Material.CAKE, (byte) 0, -15, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 2.0, Material.AIR);
}
@Override
public void enableCustom(Player player)
{
player.leaveVehicle();
player.eject();
//Remove other mounts
Manager.DeregisterAll(player);
Horse horse = UtilVariant.spawnHorse(player.getLocation(), _variant);
horse.setAdult();
horse.setAgeLock(true);
horse.setColor(_color);
horse.setStyle(_style);
horse.setOwner(player);
horse.setMaxDomestication(1);
horse.setJumpStrength(_jump);
horse.setMaxHealth(20);
horse.setHealth(horse.getMaxHealth());
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
if (horse.getVariant() == Horse.Variant.MULE)
horse.setCarryingChest(true);
if (_armor != null)
horse.getInventory().setArmor(new ItemStack(_armor));
horse.setCustomName(player.getName() + "'s " + getName());
//Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(getName()) + "."));
//Store
SingleEntityMountData<Horse> mount = new SingleEntityMountData<>(player, horse);
_active.put(player, mount);
DisguiseBlock block = new DisguiseBlock(horse, Material.CAKE_BLOCK.getId(), 0);
Manager.getDisguiseManager().disguise(block);
UtilEnt.silence(horse, true);
}
@EventHandler
public void updateBounce(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
//Collide
for (SingleEntityMountData<Horse> cakeData : getActive().values())
{
Horse cake = cakeData.getEntity();
if (cake.getPassenger() == null)
continue;
if (!(cake.getPassenger() instanceof Player))
continue;
Player player = (Player)cake.getPassenger();
if (!Recharge.Instance.usable(player, getName() + " Collide"))
continue;
for (SingleEntityMountData<Horse> otherData : getActive().values())
{
Horse other = otherData.getEntity();
if (other.equals(cake))
continue;
if (other.getPassenger() == null)
continue;
if (!(other.getPassenger() instanceof Player))
continue;
Player otherPlayer = (Player)other.getPassenger();
if (!Recharge.Instance.usable(otherPlayer, getName() + " Collide"))
continue;
//Collide
if (UtilMath.offset(cake, other) > 2)
continue;
Recharge.Instance.useForce(player, getName() + " Collide", 500);
Recharge.Instance.useForce(otherPlayer, getName() + " Collide", 500);
UtilAction.velocity(cake, UtilAlg.getTrajectory(other, cake), 1.2, false, 0, 0.8, 10, true);
UtilAction.velocity(other, UtilAlg.getTrajectory(cake, other), 1.2, false, 0, 0.8, 10, true);
cake.getWorld().playSound(cake.getLocation(), Sound.SLIME_WALK, 1f, 0.75f);
other.getWorld().playSound(other.getLocation(), Sound.SLIME_WALK, 1f, 0.75f);
}
}
}
}

View File

@ -1,10 +1,6 @@
package mineplex.core.mount.types;
import java.lang.reflect.Field;
import java.time.Month;
import java.time.YearMonth;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -12,9 +8,12 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerAnimationType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
@ -29,6 +28,7 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilVariant;
import net.minecraft.server.v1_8_R3.EntityLiving;
public class MountChicken extends HorseMount
{
@ -40,13 +40,15 @@ public class MountChicken extends HorseMount
super(manager, "Chicken Mount",
UtilText.splitLinesToArray(new String[]
{
"This isn't flying! It is falling with style."
C.cGray + "This isn't flying! It is falling with style.",
C.cRed + " ",
C.cWhite + "Left Click to Bawk"
}, LineFormat.LORE),
Material.FEATHER, (byte) 0, -1, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 2.0, Material.AIR, YearMonth.of(2017, Month.JANUARY));
Material.FEATHER, (byte) 0, -15, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 2.0, Material.AIR);
try
{
_jumpField = EntityLiving.class.getDeclaredField("aY");
_jumpField.setAccessible(false);
_jumpField.setAccessible(true);
} catch (NoSuchFieldException e)
{
e.printStackTrace();
@ -90,11 +92,23 @@ public class MountChicken extends HorseMount
_active.put(player, mount);
DisguiseChicken chicken = new DisguiseChicken(horse);
chicken.setName(player.getName() + "'s Chicken Mount");
chicken.setName(player.getName() + "'s " + getName());
Manager.getDisguiseManager().disguise(chicken);
UtilEnt.silence(horse, true);
}
@EventHandler
public void onOrderQuack(PlayerAnimationEvent event)
{
if (getActive().containsKey(event.getPlayer()) && event.getAnimationType() == PlayerAnimationType.ARM_SWING)
{
if (Recharge.Instance.use(event.getPlayer(), "Chicken Bawk", 500, false, false))
{
event.getPlayer().getWorld().playSound(getActive().get(event.getPlayer()).getEntity().getEyeLocation(), Sound.CHICKEN_IDLE, .4F, 1.0F);
}
}
}
@EventHandler
public void jump(UpdateEvent event)
@ -145,5 +159,4 @@ public class MountChicken extends HorseMount
}
}
}
}
}

View File

@ -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;
}*/
}

View File

@ -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();
}
}*/
}

View File

@ -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);
}
}

View File

@ -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()

View File

@ -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;

View File

@ -138,7 +138,7 @@ public class PowerPlayData
}
}
enum SubscriptionDuration
public static enum SubscriptionDuration
{
MONTH, YEAR
}

View File

@ -867,4 +867,5 @@ public class ReportManager
{
return NAME + " #" + reportId;
}
}

View File

@ -118,7 +118,9 @@ import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.Mount;
import mineplex.core.mount.types.MountBabyReindeer;
import mineplex.core.mount.types.MountCake;
import mineplex.core.mount.types.MountCart;
import mineplex.core.mount.types.MountChicken;
import mineplex.core.mount.types.MountFreedomHorse;
import mineplex.core.mount.types.MountFrost;
import mineplex.core.mount.types.MountMule;
@ -130,11 +132,13 @@ import mineplex.core.mount.types.MountValentinesSheep;
import mineplex.core.mount.types.MountZombie;
import mineplex.core.pet.PetManager;
import mineplex.core.pet.PetType;
import mineplex.core.powerplayclub.PowerPlayData.SubscriptionDuration;
import mineplex.core.reward.RewardPool.Type;
import mineplex.core.reward.rewards.ChestReward;
import mineplex.core.reward.rewards.GameAmplifierReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.reward.rewards.PowerPlayReward;
import mineplex.core.reward.rewards.RankReward;
import mineplex.core.reward.rewards.RuneAmplifierReward;
import mineplex.core.reward.rewards.SpinTicketReward;
@ -460,6 +464,13 @@ public class RewardManager
addReward(Type.TRICK_OR_TREAT, new UnknownPackageReward(_donationManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0));
addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.OLD, 1, 5, rarity, 150, 0));
addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.ANCIENT, 1, 5, rarity, 80, 0));
//THANKFUL
addReward(Type.THANKFUL, new SpinTicketReward(_clientManager, 1, 3, rarity, 150, 0));
addReward(Type.THANKFUL, new RuneAmplifierReward(_inventoryManager, 20, 1, 3, rarity, 120, 0));
addReward(Type.THANKFUL, new UnknownPackageReward(_donationManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0));
addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.OLD, 1, 5, rarity, 150, 0));
addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.ANCIENT, 1, 5, rarity, 80, 0));
}
public void addLegendary()
@ -618,6 +629,15 @@ public class RewardManager
addMount(Type.TRICK_OR_TREAT, getMount(MountZombie.class), rarity, 25);
addPetReward(Type.TRICK_OR_TREAT, PetType.ZOMBIE, rarity, 10);
addGadget(Type.TRICK_OR_TREAT, getGadget(MorphPumpkinKing.class), rarity, 5);
//THANKFUL
addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.MYTHICAL, 1, 3, rarity, 50, 0));
addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.ILLUMINATED, 1, 1, rarity, 30, 0));
addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.ILLUMINATED, 1, 1, rarity, 30, 0));
addMount(Type.THANKFUL, getMount(MountChicken.class), rarity, 5);
addMount(Type.THANKFUL, getMount(MountCake.class), rarity, 10);
addPetReward(Type.THANKFUL, PetType.VILLAGER, rarity, 10);
addPetReward(Type.THANKFUL, PetType.PIG_ZOMBIE, rarity, 10);
}
public UnknownPackageReward addMount(Type type, Mount<?> mount, RewardRarity rarity, int weight)
@ -907,10 +927,15 @@ public class RewardManager
//Dont give Rank Upgrade if already has Titan
if (rarity == RewardRarity.MYTHICAL)
{
if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST) && !_clientManager.Get(player).GetRank().has(Rank.TITAN))
PowerPlayReward rew = new PowerPlayReward(_clientManager, SubscriptionDuration.MONTH, rarity, 0, 0);
if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !_clientManager.Get(player).GetRank().has(Rank.TITAN))
{
return new RankReward(_clientManager, 0, 0, rarity);
}
else if (canGiveMythical && (type == RewardType.THANKFUL_CHEST) && rew.canGiveReward(player))
{
return rew;
}
else if (!canGiveMythical || _clientManager.Get(player).GetRank().has(Rank.LEGEND))
{
rarity = RewardRarity.LEGENDARY;

View File

@ -58,6 +58,7 @@ public class RewardPool
OMEGA(false),
HAUNTED(false),
TRICK_OR_TREAT(false),
THANKFUL(false),
CARL_SPINNER(true);
private boolean _useDuplicates;

View File

@ -16,6 +16,7 @@ public enum RewardType
HAUNTED_CHEST( 0, 5, 18, 0),
OMEGA_CHEST( 0, 32, 16, 2),
TRICK_OR_TREAT_CHEST(0.1, 2, 16, 0),
THANKFUL_CHEST( 0.1, 2, 16, 0),
VALENTINES_GIFT( 0, 7, 20, 20),
SPINNER_FILLER( 0.1, 1, 4, 20),
@ -44,7 +45,7 @@ public enum RewardType
else if (rand <= _legendaryChance) rarity = RewardRarity.LEGENDARY;
else if (rand <= _rareChance) rarity = RewardRarity.RARE;
else if (rand <= _uncommonChance || requiresUncommon) rarity = RewardRarity.UNCOMMON;
return rarity;
}

View File

@ -0,0 +1,68 @@
package mineplex.core.reward.rewards;
import java.time.LocalDate;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.UtilServer;
import mineplex.core.powerplayclub.PowerPlayData.SubscriptionDuration;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
public class PowerPlayReward extends Reward
{
private CoreClientManager _clientManager;
private SubscriptionDuration _duration;
public PowerPlayReward(CoreClientManager clientManager, SubscriptionDuration duration, RewardRarity rarity, int weight, int shardValue)
{
super(rarity, weight, shardValue);
_clientManager = clientManager;
_duration = duration;
}
@Override
public RewardData giveRewardCustom(Player player, RewardType rewardType)
{
if (_clientManager.getAccountId(player) == -1)
{
return getFakeRewardData(player);
}
Managers.get(BonusManager.class).getPowerPlayClubRepository().addSubscription(_clientManager.getAccountId(player), LocalDate.now(), _duration.toString().toLowerCase());
player.setMetadata("GIVEN-PPC-REWARD", new FixedMetadataValue(UtilServer.getPlugin(), System.currentTimeMillis()));
return new RewardData(getRarity().getDarkColor() + "Power Play Subscription", getRarity().getColor() + "1 " + _duration.toString().toLowerCase() + " Power Play Club Subscription", new ItemStack(Material.FIREBALL), getRarity());
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Power Play Subscription", getRarity().getColor() + "Power Play Subscription", new ItemStack(Material.FIREBALL), getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
return !(Managers.get(BonusManager.class).getPowerPlayClubRepository().getCachedData(player).isSubscribed() || player.hasMetadata("GIVEN-PPC-REWARD"));
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof PowerPlayReward)
{
return true;
}
return false;
}
}

View File

@ -34,7 +34,7 @@ public class RankReward extends Reward
if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA;
else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO;
else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND;
else if ((rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST) && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN;
else if ((rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST || rewardType == RewardType.THANKFUL_CHEST) && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN;
if (rewardType == RewardType.MYTHICAL_CHEST && _random.nextDouble() < 0.01) // 1 Percent
rank = Rank.TITAN;

View File

@ -29,7 +29,7 @@ public class WritableMineplexScoreboard extends MineplexScoreboard
private final List<WritableScoreboardLine> _lines;
// The list of lines currently buffered for drawing
private final List<String> _bufferedLines = new ArrayList<>(15);
protected final List<String> _bufferedLines = new ArrayList<>(15);
// The list of lines which were drawn in the last draw
private final List<String> _drawnLines = new ArrayList<>(15);

View File

@ -62,7 +62,13 @@ public enum TreasureStyle
ParticleType.RED_DUST,
Sound.IRONGOLEM_HIT,
Sound.IRONGOLEM_THROW
);
),
THANKFUL(
ParticleType.HAPPY_VILLAGER,
ParticleType.HAPPY_VILLAGER,
ParticleType.HAPPY_VILLAGER,
Sound.CHICKEN_IDLE,
Sound.CHICKEN_EGG_POP);
private ParticleType _secondaryParticle;
private ParticleType _chestSpawnParticle;

View File

@ -24,7 +24,9 @@ public enum TreasureType
HAUNTED(C.cGold + "Haunted Chest", "Haunted Chest", "Haunted", RewardType.HAUNTED_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.HAUNTED, true, 35000),
TRICK_OR_TREAT(C.cGold + "Trick or Treat Treasure", "Trick or Treat Chest", "TrickOrTreat", RewardType.TRICK_OR_TREAT_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.TRICK_OR_TREAT, true, 20000);
TRICK_OR_TREAT(C.cGold + "Trick or Treat Treasure", "Trick or Treat Chest", "TrickOrTreat", RewardType.TRICK_OR_TREAT_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.TRICK_OR_TREAT, true, 20000),
THANKFUL(C.cGold + "Thankful Treasure", "Thankful Chest", "ThankFul", RewardType.THANKFUL_CHEST, Material.CHEST, TreasureStyle.THANKFUL, RewardPool.Type.THANKFUL, true, 20000);
private final String _name;
private final RewardType _rewardType;

View File

@ -155,7 +155,7 @@ public class ChestSpawnAnimation extends Animation
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, _centerLocation.clone().add(0, 5, 0), spread, 0.1f, spread, 0, 30,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (getTreasure().getTreasureType() == TreasureType.ILLUMINATED)
else if (getTreasure().getTreasureType() == TreasureType.ILLUMINATED || getTreasure().getTreasureType() == TreasureType.THANKFUL)
{
Location loc = _centerLocation.clone();
loc.add(Vector.getRandom().subtract(Vector.getRandom()).multiply(0.5));

View File

@ -57,6 +57,14 @@ public class BuyChestButton implements IButton
return;
}
}
if (_chestType == TreasureType.THANKFUL)
{
if (!new File("../../update/files/EnableThankful.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
}
if (_chestType == TreasureType.FREEDOM || _chestType == TreasureType.HAUNTED)
{
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))

View File

@ -1,5 +1,6 @@
package mineplex.core.treasure.gui;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -63,6 +64,7 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
int omegaCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OMEGA.getItemName());
int hauntedCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.HAUNTED.getItemName());
int trickCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.TRICK_OR_TREAT.getItemName());
int thankCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.THANKFUL.getItemName());
List<String> shardLore = new ArrayList<>();
shardLore.add(" ");
@ -227,9 +229,44 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
}
else
{
trickLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards");
trickLore.add(" ");
hauntedLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
boolean available = new File("../../update/files/EnableTrickOrTreat.dat").exists();
if (!available)
{
trickLore.add(ChatColor.RESET + "This chest is currently unavailable");
}
else
{
trickLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards");
trickLore.add(" ");
trickLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
}
List<String> thankLore = Lists.newArrayList();
thankLore.add(" ");
thankLore.add(F.value("Thankful Chests Owned", "" + thankCount));
thankLore.add(" ");
thankLore.add(C.cGray + "The Thankful Chest is our way of");
thankLore.add(C.cGray + "showing thanks to you, containing items from Rank Upgrades to");
thankLore.add(C.cGray + "Power Play Club Subscriptions, among other things!");
thankLore.add(" ");
if (thankCount > 0)
{
thankLore.add(ChatColor.RESET + C.cGreen + "Click to Open!");
}
else
{
boolean available = new File("../../update/files/EnableThankful.dat").exists();
if (!available)
{
thankLore.add(ChatColor.RESET + "This chest is currently unavailable");
}
else
{
thankLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards");
thankLore.add(" ");
thankLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
}
ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false);
@ -242,10 +279,12 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
ItemStack omega = SkinData.OMEGA_CHEST.getSkull(C.cAquaB + "Omega Treasure", omegaLore);
ItemStack haunted = SkinData.HAUNTED_CHEST.getSkull(C.cGoldB + "Haunted Treasure", hauntedLore);
ItemStack trick = new ShopItem(Material.SKULL_ITEM, C.cGoldB + "Trick or Treat Treasure", trickLore.toArray(new String[0]), 0, false, false);
ItemStack thank = new ShopItem(Material.COOKED_CHICKEN, C.cGoldB + "Thankful Treasure", thankLore.toArray(new String[0]), 0, false, false);
addItem(49, shards);
addChest(4, trick, TreasureType.TRICK_OR_TREAT, trickCount);
addChest(3, trick, TreasureType.TRICK_OR_TREAT, trickCount);
addChest(5, thank, TreasureType.THANKFUL, thankCount);
addChest(10, christmas, TreasureType.CHRISTMAS, christmasCount);
addChest(12, freedom, TreasureType.FREEDOM, freedomCount);
addChest(14, haunted, TreasureType.HAUNTED, hauntedCount);

View File

@ -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;

View File

@ -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;

View File

@ -41,7 +41,6 @@ import com.google.common.io.ByteStreams;
import mineplex.core.Managers;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
@ -52,9 +51,11 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.creature.Creature;
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
import mineplex.core.disguise.DisguiseManager;
@ -146,6 +147,7 @@ import mineplex.minecraft.game.core.IRelation;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.Condition;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
@ -156,6 +158,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{
public static final int CLAIMABLE_RADIUS = 800;
public static final int WORLD_RADIUS = 1200;
private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000;
private static final int VIEW_DISTANCE_BLOCK_VALUE = 8;
private long _lastVisibilityRefresh = 0;
private static final TimeZone TIME_ZONE = TimeZone.getDefault();
private static ClansManager _instance;
@ -200,6 +205,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private ClassManager _classManager;
private BannerManager _bannerManager;
private AmplifierManager _amplifierManager;
private RestartManager _restartManager;
private SafeLog _safeLog;
@ -463,7 +469,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_netherManager = new NetherManager(this);
_amplifierManager = new AmplifierManager(plugin);
new RestartManager(plugin);
_restartManager = new RestartManager(plugin);
}
@Override
@ -1207,10 +1213,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_worldEvent.onDisable();
_goldManager.onDisable();
_playTracker.onDisable();
_bannerManager.onDisable();
_amplifierManager.onDisable();
_netherManager.onDisable();
_safeLog.onDisable();
_restartManager.onDisable();
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -1400,6 +1405,27 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
}
}
@EventHandler
public void refreshVisibility(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
if (UtilTime.elapsed(_lastVisibilityRefresh, PLAYER_VISIBILITY_REFRESH_RATE))
{
_lastVisibilityRefresh = System.currentTimeMillis();
Bukkit.getOnlinePlayers().stream().filter(player -> !Managers.get(ConditionManager.class).HasCondition(player, ConditionType.INVISIBILITY) && !Managers.get(ConditionManager.class).HasCondition(player, ConditionType.CLOAK) && !UtilPlayer.isSpectator(player) && !Managers.get(IncognitoManager.class).Get(player).Hidden && !Managers.get(ObserverManager.class).isObserver(player)).forEach(player ->
{
Bukkit.getOnlinePlayers().stream().filter(viewer -> UtilMath.offset2d(viewer, player) <= (Bukkit.getViewDistance() * VIEW_DISTANCE_BLOCK_VALUE)).forEach(viewer ->
{
viewer.hidePlayer(player);
viewer.showPlayer(player);
});
});
}
}
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
{

View File

@ -1,8 +1,24 @@
package mineplex.game.clans.clans.ban;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
@ -25,28 +41,13 @@ import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class ClansBanManager extends MiniPlugin
{
private static final long FREEZE_MESSAGE_INTERVAL = 10000;
private final CoreClientManager _clientManager;
private final DonationManager _donationManager;
private final ClansBanRepository _repository;
private final HashMap<UUID, Float> _frozen = new HashMap<>();
private final Map<UUID, Float> _frozen = new HashMap<>();
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
@ -106,7 +107,7 @@ public class ClansBanManager extends MiniPlugin
} catch (Exception ignored) {}
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.LOW)
public void onQuit(PlayerQuitEvent event)
{
Float walkSpeed = _frozen.remove(event.getPlayer().getUniqueId());
@ -116,7 +117,7 @@ public class ClansBanManager extends MiniPlugin
event.getPlayer().removePotionEffect(PotionEffectType.JUMP);
for (Player staff : UtilServer.GetPlayers())
{
if (_clientManager.hasRank(staff, Rank.HELPER))
if (_clientManager.hasRank(staff, Rank.CMOD))
{
UtilPlayer.message(staff, F.main(getName(), F.elem(event.getPlayer().getName()) + " has logged out while frozen!"));
}
@ -236,13 +237,10 @@ public class ClansBanManager extends MiniPlugin
@EventHandler
public void onTpHome(ClansCommandExecutedEvent event)
{
if (event.getCommand().equalsIgnoreCase("tphome"))
if (isFrozen(event.getPlayer()))
{
if (isFrozen(event.getPlayer()))
{
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while frozen!"));
}
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot use that command while frozen!"));
}
}
@ -268,7 +266,7 @@ public class ClansBanManager extends MiniPlugin
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10));
for (Player alert : UtilServer.GetPlayers())
{
if (_clientManager.hasRank(alert, Rank.HELPER))
if (_clientManager.hasRank(alert, Rank.CMOD))
{
UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!"));
}
@ -289,7 +287,7 @@ public class ClansBanManager extends MiniPlugin
player.removePotionEffect(PotionEffectType.JUMP);
for (Player alert : UtilServer.GetPlayers())
{
if (_clientManager.hasRank(alert, Rank.HELPER))
if (_clientManager.hasRank(alert, Rank.CMOD))
{
UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!"));
continue;

View File

@ -1,6 +1,7 @@
package mineplex.game.clans.clans.banners;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -38,7 +39,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
*/
public class BannerManager extends MiniPlugin
{
public final HashMap<String, ClanBanner> LoadedBanners = new HashMap<>();
public final Map<String, ClanBanner> LoadedBanners = new HashMap<>();
private final BlockFace[] _radial = { BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST };
private BannerRepository _repo;

View File

@ -1,9 +1,13 @@
package mineplex.game.clans.clans.banners;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.DyeColor;
import org.bukkit.block.banner.PatternType;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.MinecraftRepository;
import mineplex.game.clans.clans.ClanInfo;
@ -12,10 +16,6 @@ import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
import org.bukkit.DyeColor;
import org.bukkit.block.banner.PatternType;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Database repository class for banners
*/
@ -44,7 +44,7 @@ public class BannerRepository extends MinecraftRepository
* @param map The hashmap to load the banner into
* @param clan The clan whose banner to fetch
*/
public void loadBanner(final HashMap<String, ClanBanner> map, ClanInfo clan)
public void loadBanner(final Map<String, ClanBanner> map, ClanInfo clan)
{
_bannerManager.runAsync(() ->
{
@ -89,7 +89,7 @@ public class BannerRepository extends MinecraftRepository
* @param map The hashmap to load the banner into
* @param clan The clan whose banner to fetch
*/
public void loadBanners(final HashMap<String, ClanBanner> map, ClansManager clanManager)
public void loadBanners(final Map<String, ClanBanner> map, ClansManager clanManager)
{
_bannerManager.runAsync(() ->
{

View File

@ -28,7 +28,6 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.delayedtask.DelayedTask;
import mineplex.core.delayedtask.DelayedTaskClient;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
@ -138,6 +137,14 @@ public class ClansCommand extends CommandBase<ClansManager>
private void forceJoin(Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "forcejoin", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN))
{
UtilPlayer.message(caller, F.main("Clans", "This requires ADMIN+ permission."));
@ -243,7 +250,14 @@ public class ClansCommand extends CommandBase<ClansManager>
public void create(final Player caller, final String[] args)
{
System.out.println("CREATE COMMAND");
// System.out.println("CREATE COMMAND");
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "create", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
ClientClan client = Plugin.Get(caller);
@ -336,11 +350,27 @@ public class ClansCommand extends CommandBase<ClansManager>
public void delete(final Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "disband", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
Plugin.getClanUtility().delete(caller);
}
public void invite(Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "invite", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
@ -375,6 +405,13 @@ public class ClansCommand extends CommandBase<ClansManager>
//
// return;
// }
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "stuck");
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
if (DelayedTask.Instance.HasTask(caller, "Spawn Teleport"))
{
@ -460,6 +497,14 @@ public class ClansCommand extends CommandBase<ClansManager>
public void join(final Player caller, String[] args)
{
ClansCommandExecutedEvent cevent = new ClansCommandExecutedEvent(caller, "join", args);
UtilServer.getServer().getPluginManager().callEvent(cevent);
if (cevent.isCancelled())
{
return;
}
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
{
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
@ -532,6 +577,14 @@ public class ClansCommand extends CommandBase<ClansManager>
public void leave(final Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "leave");
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
final ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
@ -569,6 +622,14 @@ public class ClansCommand extends CommandBase<ClansManager>
public void kick(final Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "kick", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
final ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
@ -590,6 +651,14 @@ public class ClansCommand extends CommandBase<ClansManager>
public void promote(Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "promote", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
@ -611,6 +680,14 @@ public class ClansCommand extends CommandBase<ClansManager>
public void demote(Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "demote", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
@ -632,6 +709,14 @@ public class ClansCommand extends CommandBase<ClansManager>
public void ally(Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "ally", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
ClanInfo cA = Plugin.getClanUtility().getClanByPlayer(caller);
if (cA == null)
@ -761,6 +846,14 @@ public class ClansCommand extends CommandBase<ClansManager>
public void neutral(Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "neutral", args);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
ClanInfo cA = Plugin.getClanMemberUuidMap().get(caller.getUniqueId());
if (cA == null)
@ -843,6 +936,14 @@ public class ClansCommand extends CommandBase<ClansManager>
}
}
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "unclaim");
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
Plugin.getClanUtility().unclaim(caller, caller.getLocation().getChunk());
}
@ -867,11 +968,27 @@ public class ClansCommand extends CommandBase<ClansManager>
public void unclaimall(Player caller)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "unclaimall");
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
Plugin.getClanUtility().unclaimAll(caller);
}
public void map(Player caller, String[] args)
{
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "map");
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
Plugin.getItemMapManager().setMap(caller);
}
@ -1048,7 +1165,7 @@ public class ClansCommand extends CommandBase<ClansManager>
public void infoClan(Player caller, String search)
{
System.out.println(search);
// System.out.println(search);
if (search == null)
{
@ -1089,12 +1206,12 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null) return;
// if (_clansManager.getNetherManager().isInNether(caller))
// {
// _clansManager.message(caller, "You are currently in " + F.clansNether("The Nether") + ".");
//
// return;
// }
if (_clansManager.getNetherManager().isInNether(caller))
{
_clansManager.message(caller, "You are currently in " + F.clansNether("The Nether") + ".");
return;
}
UtilPlayer.message(caller, clan.mTerritory());
}

View File

@ -493,12 +493,12 @@ public class NetherManager extends MiniPlugin
@EventHandler
public void onTpHome(ClansCommandExecutedEvent event)
{
if (event.getCommand().equalsIgnoreCase("tphome"))
if (event.getCommand().equalsIgnoreCase("tphome") || event.getCommand().equalsIgnoreCase("stuck"))
{
if (isInNether(event.getPlayer()))
{
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while in " + F.clansNether("The Nether") + "!"));
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport while in " + F.clansNether("The Nether") + "!"));
}
}
}

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.gameplay;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@ -82,6 +83,7 @@ public class Gameplay extends MiniPlugin
{
private static final int MAX_BUILD_HEIGHT = 120;
private static final int MIN_CHEST_HEIGHT = 30;
private static final Material[] REDSTONE_TYPES = new Material[] {Material.ACTIVATOR_RAIL, Material.REDSTONE, Material.REDSTONE_BLOCK, Material.REDSTONE_COMPARATOR, Material.REDSTONE_WIRE, Material.REDSTONE_COMPARATOR_OFF, Material.REDSTONE_COMPARATOR_ON, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.REDSTONE_TORCH_OFF, Material.REDSTONE_TORCH_ON, Material.DIODE, Material.DIODE_BLOCK_OFF, Material.DIODE_BLOCK_ON, Material.DETECTOR_RAIL};
private ClansManager _clansManager;
private BlockRestore _blockRestore;
private DamageManager _damageManager;
@ -222,7 +224,7 @@ public class Gameplay extends MiniPlugin
@EventHandler(priority = EventPriority.LOWEST)
public void RedstoneCancel(BlockPlaceEvent event)
{
if (event.getBlock().getType().toString().startsWith("REDSTONE"))
if (Arrays.asList(REDSTONE_TYPES).contains(event.getBlock().getType()))
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place redstone based items."));
event.setCancelled(true);

View File

@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -22,6 +23,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ban.ClansBanManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
@ -62,6 +64,11 @@ public class SafeLog extends MiniPlugin
return;
}
if (Managers.get(ClansBanManager.class).isFrozen(player))
{
isSafeLog = true;
}
if (!isSafeLog)
{
if (!_clansManager.getIncognitoManager().Get(player).Status)

View File

@ -40,9 +40,10 @@ public class RestartManager extends MiniPlugin
_serverName = plugin.getConfig().getString("serverstatus.name");
_testServer = plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing");
if (inRestartZone(Calendar.HOUR_OF_DAY))
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if (inRestartZone(hour))
{
_restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - Calendar.HOUR_OF_DAY, TimeUnit.HOURS, TimeUnit.MILLISECONDS);
_restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - hour, TimeUnit.HOURS, TimeUnit.MILLISECONDS);
}
else
{
@ -68,7 +69,7 @@ public class RestartManager extends MiniPlugin
private boolean tryRestartTime()
{
if (!inRestartZone(Calendar.HOUR_OF_DAY) || System.currentTimeMillis() < _restartUnlock)
if (!inRestartZone(Calendar.getInstance().get(Calendar.HOUR_OF_DAY)) || System.currentTimeMillis() < _restartUnlock)
{
return false;
}
@ -100,6 +101,15 @@ public class RestartManager extends MiniPlugin
return restart;
}
@Override
public void disable()
{
if (!_testServer)
{
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has shut down!"), true);
}
}
public void restart()
{
Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(120000)) + "!"));

View File

@ -1,9 +1,49 @@
package mineplex.clanshub;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import mineplex.clanshub.commands.ForcefieldRadius;
import mineplex.clanshub.commands.GadgetToggle;
import mineplex.clanshub.commands.GameModeCommand;
import mineplex.clanshub.profile.gui.GUIProfile;
import mineplex.clanshub.salesannouncements.SalesAnnouncementManager;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
@ -81,44 +121,6 @@ import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.UUID;
/**
* Main manager for clans hub
@ -255,6 +257,8 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
_serverName = getPlugin().getConfig().getString("serverstatus.name");
_serverName = _serverName.substring(0, Math.min(16, _serverName.length()));
new SalesAnnouncementManager(plugin);
}
@Override

View File

@ -0,0 +1,41 @@
package mineplex.clanshub.salesannouncements;
import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
public class RankSelectionButton extends SalesAnnouncementGUIButton
{
private SalesAnnouncementCreationPage _page;
private Rank _rank;
public RankSelectionButton(Rank rank, SalesAnnouncementCreationPage page)
{
super(new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(rank.getColor() + (rank.Name.isEmpty() ? "Default" : rank.Name)).addLore(C.cRed + "Click to Toggle On").build());
_rank = rank;
_page = page;
}
@Override
public void update() {}
@Override
public void handleClick(ClickType type)
{
if (_page.Selected.contains(_rank))
{
Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(_rank.getColor() + (_rank.Name.isEmpty() ? "Default" : _rank.Name)).addLore(C.cRed + "Click to Toggle On").build();
_page.Selected.remove(_rank);
_page.updateButtons(true);
}
else
{
Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(_rank.getColor() + (_rank.Name.isEmpty() ? "Default" : _rank.Name)).addLore(C.cGreen + "Click to Toggle Off").build();
_page.Selected.add(_rank);
_page.updateButtons(true);
}
}
}

View File

@ -0,0 +1,40 @@
package mineplex.clanshub.salesannouncements;
import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
public class RankSelectionFinalizeButton extends SalesAnnouncementGUIButton
{
private SalesAnnouncementCreationPage _page;
public RankSelectionFinalizeButton(SalesAnnouncementCreationPage page)
{
super(new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + "Click to Finalize").addLore(C.cRed + "You must select at least one rank!").build());
_page = page;
}
@Override
public void update()
{
if (_page.Selected.isEmpty())
{
Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + "Click to Finalize").addLore(C.cRed + "You must select at least one rank!").build();
}
else
{
Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + "Click to Finalize").build();
}
}
@Override
public void handleClick(ClickType type)
{
if (!_page.Selected.isEmpty())
{
_page.finalizeSelection();
}
}
}

View File

@ -0,0 +1,40 @@
package mineplex.clanshub.salesannouncements;
import org.bukkit.event.inventory.ClickType;
public class SalesAnnouncementButton extends SalesAnnouncementGUIButton
{
private SalesAnnouncementData _data;
private SalesAnnouncementPage _page;
public SalesAnnouncementButton(SalesAnnouncementData data, SalesAnnouncementPage page)
{
super(data.getButtonForm());
_data = data;
_page = page;
}
public int getId()
{
return _data.getId();
}
@Override
public void update()
{
Button = _data.getButtonForm();
}
@Override
public void handleClick(ClickType type)
{
if (type == ClickType.RIGHT)
{
_page.deleteAnnouncement(_data);
}
else
{
_page.toggleAnnouncement(_data);
}
}
}

View File

@ -0,0 +1,40 @@
package mineplex.clanshub.salesannouncements;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class SalesAnnouncementCommand extends CommandBase<SalesAnnouncementManager>
{
public SalesAnnouncementCommand(SalesAnnouncementManager plugin)
{
super(plugin, Rank.ADMIN, "sales");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length > 1 && args[0].equalsIgnoreCase("add"))
{
StringBuilder message = new StringBuilder();
message.append(args[1]);
for (int i = 2; i < args.length; i++)
{
message.append(" " + args[i]);
}
new SalesAnnouncementCreationPage(caller, message.toString());
}
else if (args.length >= 1)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage is /sales add <Message> (can take chat color codes)"));
}
else
{
new SalesAnnouncementPage(caller, Plugin);
}
}
}

View File

@ -0,0 +1,120 @@
package mineplex.clanshub.salesannouncements;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import com.google.common.collect.Lists;
import mineplex.core.Managers;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class SalesAnnouncementCreationPage implements Listener
{
private Player _viewer;
private Inventory _inv;
private String _message;
private Map<Integer, SalesAnnouncementGUIButton> _buttons = new HashMap<>();
public List<Rank> Selected = Lists.newArrayList();
public SalesAnnouncementCreationPage(Player player, String message)
{
_viewer = player;
_message = message;
_inv = Bukkit.createInventory(player, 9 * 4, C.cGreen + "Select Ranks");
setup();
_viewer.openInventory(_inv);
UtilServer.RegisterEvents(this);
}
private void setup()
{
for (int i = 0; i < Rank.values().length; i++)
{
Rank rank = Rank.values()[i];
_buttons.put(i, new RankSelectionButton(rank, this));
}
_buttons.put(31, new RankSelectionFinalizeButton(this));
updateButtons(false);
}
private void disable()
{
HandlerList.unregisterAll(this);
}
public void finalizeSelection()
{
Managers.get(SalesAnnouncementManager.class).createAnnouncement(_viewer, Selected.toArray(new Rank[Selected.size()]), _message);
Managers.get(SalesAnnouncementManager.class).runSyncLater(() -> _viewer.closeInventory(), 1L);
}
public void updateButtons(boolean callUpdate)
{
_inv.clear();
_buttons.entrySet().stream().filter(entry -> entry.getKey() != 31).forEach(entry ->
{
if (callUpdate)
{
entry.getValue().update();
}
_inv.setItem(entry.getKey(), entry.getValue().Button);
});
if (callUpdate)
{
_buttons.get(31).update();
}
_inv.setItem(31, _buttons.get(31).Button);
_viewer.updateInventory();
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
if (event.getType() == UpdateType.TICK)
{
if (_viewer.getOpenInventory() == null || _viewer.getOpenInventory().getTopInventory() == null || !_viewer.getOpenInventory().getTopInventory().getTitle().equals(_inv.getTitle()))
{
disable();
return;
}
}
}
@EventHandler
public void handleClick(InventoryClickEvent event)
{
if (event.getClickedInventory() == null || !event.getClickedInventory().getTitle().equals(_inv.getTitle()))
{
return;
}
if (!_viewer.getName().equals(event.getWhoClicked().getName()))
{
return;
}
event.setCancelled(true);
Integer slot = event.getSlot();
if (!_buttons.containsKey(slot))
{
return;
}
_buttons.get(slot).handleClick(event.getClick());
}
}

View File

@ -0,0 +1,75 @@
package mineplex.clanshub.salesannouncements;
import java.util.Arrays;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
public class SalesAnnouncementData
{
private final int _id;
private final Rank[] _displayTo;
private final String _message;
private boolean _enabled;
public SalesAnnouncementData(int id, Rank[] displayTo, String message, boolean enabled)
{
_id = id;
_displayTo = displayTo;
_message = message;
_enabled = enabled;
}
public int getId()
{
return _id;
}
public Rank[] getDisplayTo()
{
return _displayTo;
}
public boolean shouldDisplayTo(Rank rank)
{
return Arrays.asList(_displayTo).contains(rank);
}
public String getMessage(boolean raw)
{
return raw ? _message : ChatColor.translateAlternateColorCodes('&', _message);
}
public ItemStack getButtonForm()
{
Material type = Material.REDSTONE_BLOCK;
String lore = C.cRed + "Click to Enable, Right-Click to Delete";
String excerpt = getMessage(false);
if (excerpt.length() > 9)
{
excerpt = excerpt.substring(0, 9) + C.Reset + "...";
}
if (_enabled)
{
type = Material.EMERALD_BLOCK;
lore = C.cGreen + "Click to Disable, Right-Click to Delete";
}
return new ItemBuilder(type).setTitle("ID: " + getId()).setLore(excerpt, C.cRed + " ", lore).build();
}
public boolean isEnabled()
{
return _enabled;
}
public void setEnabled(boolean enabled)
{
_enabled = enabled;
}
}

View File

@ -0,0 +1,25 @@
package mineplex.clanshub.salesannouncements;
import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementDeleteCommand extends ServerCommand
{
private int _id;
private String _from;
public SalesAnnouncementDeleteCommand(int id, String from)
{
_id = id;
_from = from;
}
public int getId()
{
return _id;
}
public String getFrom()
{
return _from;
}
}

View File

@ -0,0 +1,28 @@
package mineplex.clanshub.salesannouncements;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementDeleteHandler implements CommandCallback
{
private final SalesAnnouncementManager _manager;
public SalesAnnouncementDeleteHandler(SalesAnnouncementManager manager)
{
_manager = manager;
}
@Override
public void run(ServerCommand command)
{
if (!(command instanceof SalesAnnouncementDeleteCommand))
{
return;
}
if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementDeleteCommand) command).getFrom()))
{
return;
}
_manager.handleRemoteDeletion(((SalesAnnouncementDeleteCommand)command).getId());
}
}

View File

@ -0,0 +1,18 @@
package mineplex.clanshub.salesannouncements;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
public abstract class SalesAnnouncementGUIButton
{
public ItemStack Button = null;
public SalesAnnouncementGUIButton(ItemStack button)
{
Button = button;
}
public abstract void update();
public abstract void handleClick(ClickType type);
}

View File

@ -0,0 +1,142 @@
package mineplex.clanshub.salesannouncements;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.serverdata.commands.ServerCommandManager;
public class SalesAnnouncementManager extends MiniPlugin
{
private static final String LINE = C.cDGreenB + C.Strike + "=============================================";
private final List<SalesAnnouncementData> _data = Lists.newArrayList();
private final SalesAnnouncementRepository _repo;
public SalesAnnouncementManager(JavaPlugin plugin)
{
super("Sales", plugin);
_repo = new SalesAnnouncementRepository(plugin);
_repo.loadAnnouncements(_data);
addCommand(new SalesAnnouncementCommand(this));
ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementUpdate", SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this));
ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementDelete", SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this));
}
public List<SalesAnnouncementData> getLoadedAnnouncements()
{
return _data;
}
public String getServer()
{
return getPlugin().getConfig().getString("serverstatus.name");
}
public void createAnnouncement(Player creator, Rank[] displayTo, String message)
{
if (_data.size() >= 9 * 6)
{
UtilPlayer.message(creator, F.main(getName(), "There are too many existing Sales Announcements to create a new one! Try deleting some!"));
return;
}
_repo.createAnnouncement(displayTo, message, data ->
{
UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!"));
_data.add(data);
new SalesAnnouncementUpdateCommand(data.getId(), getServer()).publish();
});
}
public void deleteAnnouncement(Player deletor, SalesAnnouncementData data, boolean forceRemoveFromList)
{
if (forceRemoveFromList)
{
_data.remove(data);
}
_repo.deleteAnnouncement(data, () ->
{
UtilPlayer.message(deletor, F.main(getName(), "Successfully deleted announcement!"));
if (!forceRemoveFromList)
{
_data.remove(data);
}
new SalesAnnouncementDeleteCommand(data.getId(), getServer()).publish();
});
}
public void toggleAnnouncement(Player toggler, SalesAnnouncementData data)
{
data.setEnabled(!data.isEnabled());
_repo.updateAnnouncementStatus(data, () ->
{
UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!"));
new SalesAnnouncementUpdateCommand(data.getId(), getServer()).publish();
});
}
public void handleRemoteDeletion(int id)
{
_data.removeIf(data -> data.getId() == id);
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
}
public void handleRemoteUpdate(int id)
{
if (_data.stream().filter(data -> data.getId() == id).toArray().length > 0)
{
_repo.loadAnnouncement(id, data ->
{
_data.stream().filter(existing -> existing.getId() == data.getId()).forEach(existing -> existing.setEnabled(data.isEnabled()));
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
});
}
else
{
_repo.loadAnnouncement(id, data ->
{
_data.add(data);
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
});
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
if (_data.isEmpty() || _data.stream().filter(data -> data.isEnabled()).toArray().length == 0)
{
return;
}
Player player = event.getPlayer();
Rank rank = Managers.get(CoreClientManager.class).Get(player).GetRank();
runSyncLater(() ->
{
_data.stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data ->
{
player.sendMessage(" ");
player.sendMessage(LINE);
player.sendMessage(" ");
player.sendMessage(data.getMessage(false));
player.sendMessage(" ");
player.sendMessage(LINE);
player.sendMessage(" ");
});
}, 5L);
}
}

View File

@ -0,0 +1,121 @@
package mineplex.clanshub.salesannouncements;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class SalesAnnouncementPage implements Listener
{
private Player _viewer;
private Inventory _inv;
private SalesAnnouncementManager _manager;
private Map<Integer, SalesAnnouncementButton> _buttons = new HashMap<>();
public SalesAnnouncementPage(Player player, SalesAnnouncementManager manager)
{
_viewer = player;
_manager = manager;
_inv = Bukkit.createInventory(player, 9 * 6, C.cGreen + "All Sales Announcements");
setup();
_viewer.openInventory(_inv);
UtilServer.RegisterEvents(this);
}
private void setup()
{
_buttons.clear();
for (int i = 0; i < _manager.getLoadedAnnouncements().size(); i++)
{
SalesAnnouncementData data = _manager.getLoadedAnnouncements().get(i);
_buttons.put(i, new SalesAnnouncementButton(data, this));
}
updateButtons(false);
}
private void disable()
{
HandlerList.unregisterAll(this);
}
public void deleteAnnouncement(SalesAnnouncementData data)
{
_manager.deleteAnnouncement(_viewer, data, true);
_manager.runSyncLater(() -> setup(), 2L);
}
public void toggleAnnouncement(SalesAnnouncementData data)
{
_manager.toggleAnnouncement(_viewer, data);
updateButtons(true);
}
public void updateButtons(boolean callUpdate)
{
_inv.clear();
_buttons.entrySet().stream().forEach(entry ->
{
if (callUpdate)
{
entry.getValue().update();
}
_inv.setItem(entry.getKey(), entry.getValue().Button);
});
_viewer.updateInventory();
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
if (event.getType() == UpdateType.TICK)
{
if (_viewer.getOpenInventory() == null || _viewer.getOpenInventory().getTopInventory() == null || !_viewer.getOpenInventory().getTopInventory().getTitle().equals(_inv.getTitle()))
{
disable();
return;
}
}
}
@EventHandler
public void handleClick(InventoryClickEvent event)
{
if (event.getClickedInventory() == null || !event.getClickedInventory().getTitle().equals(_inv.getTitle()))
{
return;
}
if (!_viewer.getName().equals(event.getWhoClicked().getName()))
{
return;
}
event.setCancelled(true);
Integer slot = event.getSlot();
if (!_buttons.containsKey(slot))
{
return;
}
_buttons.get(slot).handleClick(event.getClick());
}
@EventHandler
public void onListChange(SalesAnnouncementRemoteListUpdateEvent event)
{
setup();
}
}

View File

@ -0,0 +1,21 @@
package mineplex.clanshub.salesannouncements;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class SalesAnnouncementRemoteListUpdateEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public SalesAnnouncementRemoteListUpdateEvent() {}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,174 @@
package mineplex.clanshub.salesannouncements;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnBoolean;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
public class SalesAnnouncementRepository extends MinecraftRepository
{
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, PRIMARY KEY (id));";
private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements;";
private static final String GET_ANNOUNCEMENT = "SELECT * FROM salesAnnouncements WHERE id=?;";
private static final String UPDATE_ANNOUNCEMENT_STATUS = "UPDATE salesAnnouncements SET enabled=? WHERE id=?;";
private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled) VALUES(?, ?, ?);";
private static final String DELETE_ANNOUNCEMENT = "DELETE FROM salesAnnouncements WHERE id=?;";
private final JavaPlugin _plugin;
public SalesAnnouncementRepository(JavaPlugin plugin)
{
super(plugin, DBPool.getAccount());
_plugin = plugin;
}
private void runAsync(Runnable runnable)
{
Bukkit.getScheduler().runTaskAsynchronously(_plugin, runnable);
}
private void runSync(Runnable runnable)
{
Bukkit.getScheduler().runTask(_plugin, runnable);
}
public void loadAnnouncements(final List<SalesAnnouncementData> announcementList)
{
runAsync(() ->
{
executeQuery(GET_ANNOUNCEMENTS, resultSet ->
{
final List<SalesAnnouncementData> data = Lists.newArrayList();
while (resultSet.next())
{
int id = resultSet.getInt("id");
String rankString = resultSet.getString("ranks");
List<Rank> ranks = Lists.newArrayList();
if (rankString.contains(",") && !rankString.startsWith(",") && !rankString.endsWith(","))
{
for (String rankStr : rankString.split(","))
{
ranks.add(Rank.valueOf(rankStr));
}
}
else
{
ranks.add(Rank.valueOf(rankString));
}
Rank[] displayTo = ranks.toArray(new Rank[ranks.size()]);
String message = resultSet.getString("message");
boolean enabled = resultSet.getBoolean("enabled");
data.add(new SalesAnnouncementData(id, displayTo, message, enabled));
}
runSync(() ->
{
announcementList.clear();
data.forEach(sData -> announcementList.add(sData));
});
});
});
}
public void loadAnnouncement(final int id, final Callback<SalesAnnouncementData> callback)
{
runAsync(() ->
{
executeQuery(GET_ANNOUNCEMENT, resultSet ->
{
if (resultSet.next())
{
int aId = resultSet.getInt("id");
String rankString = resultSet.getString("ranks");
List<Rank> ranks = Lists.newArrayList();
if (rankString.contains(",") && !rankString.startsWith(",") && !rankString.endsWith(","))
{
for (String rankStr : rankString.split(","))
{
ranks.add(Rank.valueOf(rankStr));
}
}
else
{
ranks.add(Rank.valueOf(rankString));
}
Rank[] displayTo = ranks.toArray(new Rank[ranks.size()]);
String message = resultSet.getString("message");
boolean enabled = resultSet.getBoolean("enabled");
final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled);
runSync(() ->
{
callback.run(data);
});
}
}, new ColumnInt("id", id));
});
}
public void createAnnouncement(final Rank[] displayTo, final String message, Callback<SalesAnnouncementData> callback)
{
runAsync(() ->
{
String rankStr = displayTo[0].toString();
for (int i = 1; i < displayTo.length; i++)
{
rankStr += ("," + displayTo[i].toString());
}
executeInsert(INSERT_ANNOUNCEMENT, resultSet ->
{
if (resultSet.next())
{
int id = resultSet.getInt(1);
final SalesAnnouncementData data = new SalesAnnouncementData(id, displayTo, message, true);
if (callback != null)
{
runSync(() -> callback.run(data));
}
}
}, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true));
});
}
public void updateAnnouncementStatus(SalesAnnouncementData data, Runnable after)
{
runAsync(() ->
{
executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId()));
if (after != null)
{
runSync(after);
}
});
}
public void deleteAnnouncement(SalesAnnouncementData data, Runnable after)
{
runAsync(() ->
{
executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId()));
if (after != null)
{
runSync(after);
}
});
}
@Override
protected void initialize() {}
@Override
protected void update() {}
}

View File

@ -0,0 +1,25 @@
package mineplex.clanshub.salesannouncements;
import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementUpdateCommand extends ServerCommand
{
private int _id;
private String _from;
public SalesAnnouncementUpdateCommand(int id, String from)
{
_id = id;
_from = from;
}
public int getId()
{
return _id;
}
public String getFrom()
{
return _from;
}
}

View File

@ -0,0 +1,28 @@
package mineplex.clanshub.salesannouncements;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementUpdateHandler implements CommandCallback
{
private final SalesAnnouncementManager _manager;
public SalesAnnouncementUpdateHandler(SalesAnnouncementManager manager)
{
_manager = manager;
}
@Override
public void run(ServerCommand command)
{
if (!(command instanceof SalesAnnouncementUpdateCommand))
{
return;
}
if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementUpdateCommand) command).getFrom()))
{
return;
}
_manager.handleRemoteUpdate(((SalesAnnouncementUpdateCommand)command).getId());
}
}

View File

@ -4,13 +4,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.UUID;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -125,13 +118,19 @@ import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.SoccerManager;
import mineplex.hub.modules.ValentinesManager;
import mineplex.hub.modules.WorldManager;
import mineplex.hub.modules.nonpremium.NonPremiumManager;
import mineplex.hub.modules.salesannouncements.SalesAnnouncementManager;
import mineplex.hub.profile.gui.GUIProfile;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.ConditionManager;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter
{
@ -273,7 +272,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
_valentinesManager = new ValentinesManager(plugin, clientManager, donationManager);
new NonPremiumManager(plugin, clientManager);
new SalesAnnouncementManager(plugin);
ScoreboardManager scoreboardManager = new ScoreboardManager(plugin)
{

View File

@ -1,84 +0,0 @@
package mineplex.hub.modules.nonpremium;
import mineplex.core.progression.util.SQLStatement;
import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
*/
public class MessageRepository
{
private static final String SCHEMA = "CREATE TABLE IF NOT EXISTS nonPremiumJoinMessage (message VARCHAR(256));";
private static final String QUERY = "SELECT `message` FROM `nonPremiumJoinMessage`;";
private static final String UPDATE = "UPDATE `nonPremiumJoinMessage` SET `message` = ?;";
private static final String INSERT = "INSERT INTO `nonPremiumJoinMessage` VALUES(?);";
private final JavaPlugin _plugin;
private String _message;
public MessageRepository(JavaPlugin plugin)
{
_plugin = plugin;
}
/**
* Update the message globally.
*
* @param message The new string literal message
*/
public void updateMessage(String message)
{
_message = message;
async(() -> {
try (Connection connection = DBPool.getAccount().getConnection())
{
ResultSet resultSet = new SQLStatement(QUERY).prepare(connection).executeQuery();
if (!resultSet.next())
{
new SQLStatement(INSERT).set(1, message).prepare(connection).executeUpdate();
} else
{
new SQLStatement(UPDATE).set(1, message).prepare(connection).executeUpdate();
}
} catch (SQLException e)
{
e.printStackTrace();
}
});
}
private void async(Runnable runnable)
{
Bukkit.getScheduler().runTaskAsynchronously(_plugin, runnable);
}
public String getMessage()
{
if (_message == null)
{
try (Connection connection = DBPool.getAccount().getConnection())
{
ResultSet resultSet = new SQLStatement(QUERY).prepare(connection).executeQuery();
if (resultSet == null || !resultSet.next())
{
return null;
}
_message = resultSet.getString(1);
} catch (SQLException e)
{
e.printStackTrace();
}
}
return _message;
}
}

View File

@ -1,47 +0,0 @@
package mineplex.hub.modules.nonpremium;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/**
*
*/
public class NPUMCommand extends CommandBase<NonPremiumManager>
{
public NPUMCommand(NonPremiumManager plugin)
{
super(plugin, Rank.ADMIN, "updatemessage");
}
@Override
public void Execute(Player caller, String[] args)
{
if(!Plugin.getClientManager().Get(caller).GetRank().has(Rank.ADMIN)) {
caller.sendMessage(C.cRed + "No.");
return;
}
if(args.length == 0) {
caller.sendMessage(F.main("NPUM", "Invalid Command Arguments. Usage: /updatemessage \"Message here\". Use '&' for color codes. Spaces are allowed."));
return;
}
StringBuilder message = new StringBuilder();
for(int i = 0; i < args.length; i++) {
message.append(args[i]);
if((i + 1) != args.length) {
message.append(" ");
}
}
Plugin.setMessage(message.toString(), true);
caller.sendMessage(F.main("NPUM", "Non-Premium User message updated. New message: "));
caller.sendMessage(ChatColor.translateAlternateColorCodes('&', message.toString()));
}
}

View File

@ -1,84 +0,0 @@
package mineplex.hub.modules.nonpremium;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.serverdata.commands.ServerCommandManager;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
/**
*
*/
public class NonPremiumManager extends MiniPlugin
{
private static final String LINE = C.cDGreenB + C.Strike + "=============================================";
private String _message;
private MessageRepository _messageRepository;
private CoreClientManager _clientManager;
public NonPremiumManager(JavaPlugin plugin, CoreClientManager clientManager)
{
super("NonPremiumPlayerManager", plugin);
addCommand(new NPUMCommand(this));
_clientManager = clientManager;
_messageRepository = new MessageRepository(plugin);
_message = _messageRepository.getMessage();
UpdateMessageHandler handler = new UpdateMessageHandler(this);
ServerCommandManager.getInstance().registerCommandType(UpdateMessageCommand.class, handler);
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
Rank rank = _clientManager.Get(player).GetRank();
if (_message == null)
{
return;
}
if (rank != Rank.ALL)
{
return;
}
getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> {
player.sendMessage(" ");
player.sendMessage(LINE);
player.sendMessage(" ");
player.sendMessage(ChatColor.translateAlternateColorCodes('&', _message));
player.sendMessage(" ");
player.sendMessage(LINE);
player.sendMessage(" ");
player.sendMessage(" ");
}, 5L);
}
public void setMessage(String message, boolean updateDB)
{
_message = message;
if (!updateDB)
{
return;
}
_messageRepository.updateMessage(message);
ServerCommandManager.getInstance().publishCommand(new UpdateMessageCommand(message, getServer()));
}
public CoreClientManager getClientManager()
{
return _clientManager;
}
public String getServer() {
return getPlugin().getConfig().getString("serverstatus.name");
}
}

View File

@ -1,28 +0,0 @@
package mineplex.hub.modules.nonpremium;
import mineplex.serverdata.commands.ServerCommand;
/**
*
*/
public class UpdateMessageCommand extends ServerCommand
{
private String _message;
private String _from;
public UpdateMessageCommand(String message, String from) {
_message = message;
_from = from;
}
public String getMessage()
{
return _message;
}
public String getFrom()
{
return _from;
}
}

View File

@ -1,29 +0,0 @@
package mineplex.hub.modules.nonpremium;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
/**
*
*/
public class UpdateMessageHandler implements CommandCallback
{
private final NonPremiumManager _manager;
public UpdateMessageHandler(NonPremiumManager manager) {
_manager = manager;
}
@Override
public void run(ServerCommand command)
{
if(!(command instanceof UpdateMessageCommand)) {
return;
}
if(_manager.getServer().equalsIgnoreCase(((UpdateMessageCommand) command).getFrom())) {
return;
}
_manager.setMessage(((UpdateMessageCommand) command).getMessage(), false);
}
}

View File

@ -0,0 +1,41 @@
package mineplex.hub.modules.salesannouncements;
import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
public class RankSelectionButton extends SalesAnnouncementGUIButton
{
private SalesAnnouncementCreationPage _page;
private Rank _rank;
public RankSelectionButton(Rank rank, SalesAnnouncementCreationPage page)
{
super(new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(rank.getColor() + (rank.Name.isEmpty() ? "Default" : rank.Name)).addLore(C.cRed + "Click to Toggle On").build());
_rank = rank;
_page = page;
}
@Override
public void update() {}
@Override
public void handleClick(ClickType type)
{
if (_page.Selected.contains(_rank))
{
Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(_rank.getColor() + (_rank.Name.isEmpty() ? "Default" : _rank.Name)).addLore(C.cRed + "Click to Toggle On").build();
_page.Selected.remove(_rank);
_page.updateButtons(true);
}
else
{
Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(_rank.getColor() + (_rank.Name.isEmpty() ? "Default" : _rank.Name)).addLore(C.cGreen + "Click to Toggle Off").build();
_page.Selected.add(_rank);
_page.updateButtons(true);
}
}
}

View File

@ -0,0 +1,40 @@
package mineplex.hub.modules.salesannouncements;
import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
public class RankSelectionFinalizeButton extends SalesAnnouncementGUIButton
{
private SalesAnnouncementCreationPage _page;
public RankSelectionFinalizeButton(SalesAnnouncementCreationPage page)
{
super(new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + "Click to Finalize").addLore(C.cRed + "You must select at least one rank!").build());
_page = page;
}
@Override
public void update()
{
if (_page.Selected.isEmpty())
{
Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + "Click to Finalize").addLore(C.cRed + "You must select at least one rank!").build();
}
else
{
Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + "Click to Finalize").build();
}
}
@Override
public void handleClick(ClickType type)
{
if (!_page.Selected.isEmpty())
{
_page.finalizeSelection();
}
}
}

View File

@ -0,0 +1,40 @@
package mineplex.hub.modules.salesannouncements;
import org.bukkit.event.inventory.ClickType;
public class SalesAnnouncementButton extends SalesAnnouncementGUIButton
{
private SalesAnnouncementData _data;
private SalesAnnouncementPage _page;
public SalesAnnouncementButton(SalesAnnouncementData data, SalesAnnouncementPage page)
{
super(data.getButtonForm());
_data = data;
_page = page;
}
public int getId()
{
return _data.getId();
}
@Override
public void update()
{
Button = _data.getButtonForm();
}
@Override
public void handleClick(ClickType type)
{
if (type == ClickType.RIGHT)
{
_page.deleteAnnouncement(_data);
}
else
{
_page.toggleAnnouncement(_data);
}
}
}

View File

@ -0,0 +1,40 @@
package mineplex.hub.modules.salesannouncements;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class SalesAnnouncementCommand extends CommandBase<SalesAnnouncementManager>
{
public SalesAnnouncementCommand(SalesAnnouncementManager plugin)
{
super(plugin, Rank.ADMIN, "sales");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length > 1 && args[0].equalsIgnoreCase("add"))
{
StringBuilder message = new StringBuilder();
message.append(args[1]);
for (int i = 2; i < args.length; i++)
{
message.append(" " + args[i]);
}
new SalesAnnouncementCreationPage(caller, message.toString());
}
else if (args.length >= 1)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage is /sales add <Message> (can take chat color codes)"));
}
else
{
new SalesAnnouncementPage(caller, Plugin);
}
}
}

View File

@ -0,0 +1,120 @@
package mineplex.hub.modules.salesannouncements;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import com.google.common.collect.Lists;
import mineplex.core.Managers;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class SalesAnnouncementCreationPage implements Listener
{
private Player _viewer;
private Inventory _inv;
private String _message;
private Map<Integer, SalesAnnouncementGUIButton> _buttons = new HashMap<>();
public List<Rank> Selected = Lists.newArrayList();
public SalesAnnouncementCreationPage(Player player, String message)
{
_viewer = player;
_message = message;
_inv = Bukkit.createInventory(player, 9 * 4, C.cGreen + "Select Ranks");
setup();
_viewer.openInventory(_inv);
UtilServer.RegisterEvents(this);
}
private void setup()
{
for (int i = 0; i < Rank.values().length; i++)
{
Rank rank = Rank.values()[i];
_buttons.put(i, new RankSelectionButton(rank, this));
}
_buttons.put(31, new RankSelectionFinalizeButton(this));
updateButtons(false);
}
private void disable()
{
HandlerList.unregisterAll(this);
}
public void finalizeSelection()
{
Managers.get(SalesAnnouncementManager.class).createAnnouncement(_viewer, Selected.toArray(new Rank[Selected.size()]), _message);
Managers.get(SalesAnnouncementManager.class).runSyncLater(() -> _viewer.closeInventory(), 1L);
}
public void updateButtons(boolean callUpdate)
{
_inv.clear();
_buttons.entrySet().stream().filter(entry -> entry.getKey() != 31).forEach(entry ->
{
if (callUpdate)
{
entry.getValue().update();
}
_inv.setItem(entry.getKey(), entry.getValue().Button);
});
if (callUpdate)
{
_buttons.get(31).update();
}
_inv.setItem(31, _buttons.get(31).Button);
_viewer.updateInventory();
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
if (event.getType() == UpdateType.TICK)
{
if (_viewer.getOpenInventory() == null || _viewer.getOpenInventory().getTopInventory() == null || !_viewer.getOpenInventory().getTopInventory().getTitle().equals(_inv.getTitle()))
{
disable();
return;
}
}
}
@EventHandler
public void handleClick(InventoryClickEvent event)
{
if (event.getClickedInventory() == null || !event.getClickedInventory().getTitle().equals(_inv.getTitle()))
{
return;
}
if (!_viewer.getName().equals(event.getWhoClicked().getName()))
{
return;
}
event.setCancelled(true);
Integer slot = event.getSlot();
if (!_buttons.containsKey(slot))
{
return;
}
_buttons.get(slot).handleClick(event.getClick());
}
}

View File

@ -0,0 +1,75 @@
package mineplex.hub.modules.salesannouncements;
import java.util.Arrays;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
public class SalesAnnouncementData
{
private final int _id;
private final Rank[] _displayTo;
private final String _message;
private boolean _enabled;
public SalesAnnouncementData(int id, Rank[] displayTo, String message, boolean enabled)
{
_id = id;
_displayTo = displayTo;
_message = message;
_enabled = enabled;
}
public int getId()
{
return _id;
}
public Rank[] getDisplayTo()
{
return _displayTo;
}
public boolean shouldDisplayTo(Rank rank)
{
return Arrays.asList(_displayTo).contains(rank);
}
public String getMessage(boolean raw)
{
return raw ? _message : ChatColor.translateAlternateColorCodes('&', _message);
}
public ItemStack getButtonForm()
{
Material type = Material.REDSTONE_BLOCK;
String lore = C.cRed + "Click to Enable, Right-Click to Delete";
String excerpt = getMessage(false);
if (excerpt.length() > 9)
{
excerpt = excerpt.substring(0, 9) + C.Reset + "...";
}
if (_enabled)
{
type = Material.EMERALD_BLOCK;
lore = C.cGreen + "Click to Disable, Right-Click to Delete";
}
return new ItemBuilder(type).setTitle("ID: " + getId()).setLore(excerpt, C.cRed + " ", lore).build();
}
public boolean isEnabled()
{
return _enabled;
}
public void setEnabled(boolean enabled)
{
_enabled = enabled;
}
}

View File

@ -0,0 +1,25 @@
package mineplex.hub.modules.salesannouncements;
import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementDeleteCommand extends ServerCommand
{
private int _id;
private String _from;
public SalesAnnouncementDeleteCommand(int id, String from)
{
_id = id;
_from = from;
}
public int getId()
{
return _id;
}
public String getFrom()
{
return _from;
}
}

View File

@ -0,0 +1,28 @@
package mineplex.hub.modules.salesannouncements;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementDeleteHandler implements CommandCallback
{
private final SalesAnnouncementManager _manager;
public SalesAnnouncementDeleteHandler(SalesAnnouncementManager manager)
{
_manager = manager;
}
@Override
public void run(ServerCommand command)
{
if (!(command instanceof SalesAnnouncementDeleteCommand))
{
return;
}
if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementDeleteCommand) command).getFrom()))
{
return;
}
_manager.handleRemoteDeletion(((SalesAnnouncementDeleteCommand)command).getId());
}
}

View File

@ -0,0 +1,18 @@
package mineplex.hub.modules.salesannouncements;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
public abstract class SalesAnnouncementGUIButton
{
public ItemStack Button = null;
public SalesAnnouncementGUIButton(ItemStack button)
{
Button = button;
}
public abstract void update();
public abstract void handleClick(ClickType type);
}

View File

@ -0,0 +1,142 @@
package mineplex.hub.modules.salesannouncements;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.serverdata.commands.ServerCommandManager;
public class SalesAnnouncementManager extends MiniPlugin
{
private static final String LINE = C.cDGreenB + C.Strike + "=============================================";
private final List<SalesAnnouncementData> _data = Lists.newArrayList();
private final SalesAnnouncementRepository _repo;
public SalesAnnouncementManager(JavaPlugin plugin)
{
super("Sales", plugin);
_repo = new SalesAnnouncementRepository(plugin);
_repo.loadAnnouncements(_data);
addCommand(new SalesAnnouncementCommand(this));
ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementUpdate", SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this));
ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementDelete", SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this));
}
public List<SalesAnnouncementData> getLoadedAnnouncements()
{
return _data;
}
public String getServer()
{
return getPlugin().getConfig().getString("serverstatus.name");
}
public void createAnnouncement(Player creator, Rank[] displayTo, String message)
{
if (_data.size() >= 9 * 6)
{
UtilPlayer.message(creator, F.main(getName(), "There are too many existing Sales Announcements to create a new one! Try deleting some!"));
return;
}
_repo.createAnnouncement(displayTo, message, data ->
{
UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!"));
_data.add(data);
new SalesAnnouncementUpdateCommand(data.getId(), getServer()).publish();
});
}
public void deleteAnnouncement(Player deletor, SalesAnnouncementData data, boolean forceRemoveFromList)
{
if (forceRemoveFromList)
{
_data.remove(data);
}
_repo.deleteAnnouncement(data, () ->
{
UtilPlayer.message(deletor, F.main(getName(), "Successfully deleted announcement!"));
if (!forceRemoveFromList)
{
_data.remove(data);
}
new SalesAnnouncementDeleteCommand(data.getId(), getServer()).publish();
});
}
public void toggleAnnouncement(Player toggler, SalesAnnouncementData data)
{
data.setEnabled(!data.isEnabled());
_repo.updateAnnouncementStatus(data, () ->
{
UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!"));
new SalesAnnouncementUpdateCommand(data.getId(), getServer()).publish();
});
}
public void handleRemoteDeletion(int id)
{
_data.removeIf(data -> data.getId() == id);
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
}
public void handleRemoteUpdate(int id)
{
if (_data.stream().filter(data -> data.getId() == id).toArray().length > 0)
{
_repo.loadAnnouncement(id, data ->
{
_data.stream().filter(existing -> existing.getId() == data.getId()).forEach(existing -> existing.setEnabled(data.isEnabled()));
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
});
}
else
{
_repo.loadAnnouncement(id, data ->
{
_data.add(data);
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
});
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
if (_data.isEmpty() || _data.stream().filter(data -> data.isEnabled()).toArray().length == 0)
{
return;
}
Player player = event.getPlayer();
Rank rank = Managers.get(CoreClientManager.class).Get(player).GetRank();
runSyncLater(() ->
{
_data.stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data ->
{
player.sendMessage(" ");
player.sendMessage(LINE);
player.sendMessage(" ");
player.sendMessage(data.getMessage(false));
player.sendMessage(" ");
player.sendMessage(LINE);
player.sendMessage(" ");
});
}, 5L);
}
}

View File

@ -0,0 +1,121 @@
package mineplex.hub.modules.salesannouncements;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class SalesAnnouncementPage implements Listener
{
private Player _viewer;
private Inventory _inv;
private SalesAnnouncementManager _manager;
private Map<Integer, SalesAnnouncementButton> _buttons = new HashMap<>();
public SalesAnnouncementPage(Player player, SalesAnnouncementManager manager)
{
_viewer = player;
_manager = manager;
_inv = Bukkit.createInventory(player, 9 * 6, C.cGreen + "All Sales Announcements");
setup();
_viewer.openInventory(_inv);
UtilServer.RegisterEvents(this);
}
private void setup()
{
_buttons.clear();
for (int i = 0; i < _manager.getLoadedAnnouncements().size(); i++)
{
SalesAnnouncementData data = _manager.getLoadedAnnouncements().get(i);
_buttons.put(i, new SalesAnnouncementButton(data, this));
}
updateButtons(false);
}
private void disable()
{
HandlerList.unregisterAll(this);
}
public void deleteAnnouncement(SalesAnnouncementData data)
{
_manager.deleteAnnouncement(_viewer, data, true);
_manager.runSyncLater(() -> setup(), 2L);
}
public void toggleAnnouncement(SalesAnnouncementData data)
{
_manager.toggleAnnouncement(_viewer, data);
updateButtons(true);
}
public void updateButtons(boolean callUpdate)
{
_inv.clear();
_buttons.entrySet().stream().forEach(entry ->
{
if (callUpdate)
{
entry.getValue().update();
}
_inv.setItem(entry.getKey(), entry.getValue().Button);
});
_viewer.updateInventory();
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
if (event.getType() == UpdateType.TICK)
{
if (_viewer.getOpenInventory() == null || _viewer.getOpenInventory().getTopInventory() == null || !_viewer.getOpenInventory().getTopInventory().getTitle().equals(_inv.getTitle()))
{
disable();
return;
}
}
}
@EventHandler
public void handleClick(InventoryClickEvent event)
{
if (event.getClickedInventory() == null || !event.getClickedInventory().getTitle().equals(_inv.getTitle()))
{
return;
}
if (!_viewer.getName().equals(event.getWhoClicked().getName()))
{
return;
}
event.setCancelled(true);
Integer slot = event.getSlot();
if (!_buttons.containsKey(slot))
{
return;
}
_buttons.get(slot).handleClick(event.getClick());
}
@EventHandler
public void onListChange(SalesAnnouncementRemoteListUpdateEvent event)
{
setup();
}
}

View File

@ -0,0 +1,21 @@
package mineplex.hub.modules.salesannouncements;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class SalesAnnouncementRemoteListUpdateEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public SalesAnnouncementRemoteListUpdateEvent() {}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,174 @@
package mineplex.hub.modules.salesannouncements;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnBoolean;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
public class SalesAnnouncementRepository extends MinecraftRepository
{
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, PRIMARY KEY (id));";
private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements;";
private static final String GET_ANNOUNCEMENT = "SELECT * FROM salesAnnouncements WHERE id=?;";
private static final String UPDATE_ANNOUNCEMENT_STATUS = "UPDATE salesAnnouncements SET enabled=? WHERE id=?;";
private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled) VALUES(?, ?, ?);";
private static final String DELETE_ANNOUNCEMENT = "DELETE FROM salesAnnouncements WHERE id=?;";
private final JavaPlugin _plugin;
public SalesAnnouncementRepository(JavaPlugin plugin)
{
super(plugin, DBPool.getAccount());
_plugin = plugin;
}
private void runAsync(Runnable runnable)
{
Bukkit.getScheduler().runTaskAsynchronously(_plugin, runnable);
}
private void runSync(Runnable runnable)
{
Bukkit.getScheduler().runTask(_plugin, runnable);
}
public void loadAnnouncements(final List<SalesAnnouncementData> announcementList)
{
runAsync(() ->
{
executeQuery(GET_ANNOUNCEMENTS, resultSet ->
{
final List<SalesAnnouncementData> data = Lists.newArrayList();
while (resultSet.next())
{
int id = resultSet.getInt("id");
String rankString = resultSet.getString("ranks");
List<Rank> ranks = Lists.newArrayList();
if (rankString.contains(",") && !rankString.startsWith(",") && !rankString.endsWith(","))
{
for (String rankStr : rankString.split(","))
{
ranks.add(Rank.valueOf(rankStr));
}
}
else
{
ranks.add(Rank.valueOf(rankString));
}
Rank[] displayTo = ranks.toArray(new Rank[ranks.size()]);
String message = resultSet.getString("message");
boolean enabled = resultSet.getBoolean("enabled");
data.add(new SalesAnnouncementData(id, displayTo, message, enabled));
}
runSync(() ->
{
announcementList.clear();
data.forEach(sData -> announcementList.add(sData));
});
});
});
}
public void loadAnnouncement(final int id, final Callback<SalesAnnouncementData> callback)
{
runAsync(() ->
{
executeQuery(GET_ANNOUNCEMENT, resultSet ->
{
if (resultSet.next())
{
int aId = resultSet.getInt("id");
String rankString = resultSet.getString("ranks");
List<Rank> ranks = Lists.newArrayList();
if (rankString.contains(",") && !rankString.startsWith(",") && !rankString.endsWith(","))
{
for (String rankStr : rankString.split(","))
{
ranks.add(Rank.valueOf(rankStr));
}
}
else
{
ranks.add(Rank.valueOf(rankString));
}
Rank[] displayTo = ranks.toArray(new Rank[ranks.size()]);
String message = resultSet.getString("message");
boolean enabled = resultSet.getBoolean("enabled");
final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled);
runSync(() ->
{
callback.run(data);
});
}
}, new ColumnInt("id", id));
});
}
public void createAnnouncement(final Rank[] displayTo, final String message, Callback<SalesAnnouncementData> callback)
{
runAsync(() ->
{
String rankStr = displayTo[0].toString();
for (int i = 1; i < displayTo.length; i++)
{
rankStr += ("," + displayTo[i].toString());
}
executeInsert(INSERT_ANNOUNCEMENT, resultSet ->
{
if (resultSet.next())
{
int id = resultSet.getInt(1);
final SalesAnnouncementData data = new SalesAnnouncementData(id, displayTo, message, true);
if (callback != null)
{
runSync(() -> callback.run(data));
}
}
}, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true));
});
}
public void updateAnnouncementStatus(SalesAnnouncementData data, Runnable after)
{
runAsync(() ->
{
executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId()));
if (after != null)
{
runSync(after);
}
});
}
public void deleteAnnouncement(SalesAnnouncementData data, Runnable after)
{
runAsync(() ->
{
executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId()));
if (after != null)
{
runSync(after);
}
});
}
@Override
protected void initialize() {}
@Override
protected void update() {}
}

View File

@ -0,0 +1,25 @@
package mineplex.hub.modules.salesannouncements;
import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementUpdateCommand extends ServerCommand
{
private int _id;
private String _from;
public SalesAnnouncementUpdateCommand(int id, String from)
{
_id = id;
_from = from;
}
public int getId()
{
return _id;
}
public String getFrom()
{
return _from;
}
}

View File

@ -0,0 +1,28 @@
package mineplex.hub.modules.salesannouncements;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementUpdateHandler implements CommandCallback
{
private final SalesAnnouncementManager _manager;
public SalesAnnouncementUpdateHandler(SalesAnnouncementManager manager)
{
_manager = manager;
}
@Override
public void run(ServerCommand command)
{
if (!(command instanceof SalesAnnouncementUpdateCommand))
{
return;
}
if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementUpdateCommand) command).getFrom()))
{
return;
}
_manager.handleRemoteUpdate(((SalesAnnouncementUpdateCommand)command).getId());
}
}

View File

@ -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);
}
}

View File

@ -50,7 +50,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "If you lose, chickens will devour you!"
}, "BBB", "Bawk_Bawk_Battles", new SelectBawkButton(this));
add(3, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[]
add(4, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[]
{
C.Reset + "",
C.Reset + "Memorize Gwen the Guardian's builds",
@ -58,15 +58,6 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "The least correct builder is eliminated.",
}, "SB", "Speed_Builders", new SelectSBButton(this));
add(5, Material.BOW, C.cYellowB + "OITQ Payload " + C.cGray + "Fast Paced Tug of War", new String[]
{
(_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME",
C.Reset + "",
C.Reset + "1.9 Team-Based Combat Game",
C.Reset + "Keep the Payload away from your base",
C.Reset + "or die trying!",
}, "OITQP", "OITQ_Payload", new SelectOITQPButton(this));
add(7, Material.TNT, C.cYellowB + "Dragon Escape " + C.cGray + "Fast Paced Parkour", new String[]
{
(_extraValue ? C.cAquaB : C.cWhiteB) + "FEATURED ARCADE GAME",
@ -275,7 +266,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.GOLD_BOOTS)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -293,7 +286,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.DRAGON_EGG)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -311,7 +306,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.BOW)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -329,7 +326,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.LEATHER_BOOTS)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -347,7 +346,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.EMERALD)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -365,7 +366,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.LAVA_BUCKET)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -383,7 +386,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.DIAMOND_BARDING)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -401,7 +406,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.STAINED_CLAY, 1, (byte) 14)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -419,7 +426,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.IRON_BOOTS)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -437,7 +446,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + C.Bold + C.cGreen + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.PORK)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -455,7 +466,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + C.Bold + C.cGreen + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.EGG)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -473,7 +486,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + C.Bold + C.cGreen + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.EMPTY_MAP)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -491,7 +506,49 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + C.Bold + C.cGreen + "Monster Maze").setHideInfo(true));
C.Reset + C.Bold + C.cGreen + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.SKULL_ITEM).setData((short)1)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
C.Reset + "Play all of these fun minigames and more!",
C.Reset + "",
C.Reset + "Super Spleef",
C.Reset + "Runner",
C.Reset + "Dragons",
C.Reset + "One in the Quiver",
C.Reset + "Dragon Escape",
C.Reset + "Sneaky Assassins",
C.Reset + "Micro Battle",
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze",
C.Reset + C.Bold + C.cGreen + "Wither Assault",
C.Reset + "Evolution").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.IRON_INGOT)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
C.Reset + "Play all of these fun minigames and more!",
C.Reset + "",
C.Reset + "Super Spleef",
C.Reset + "Runner",
C.Reset + "Dragons",
C.Reset + "One in the Quiver",
C.Reset + "Dragon Escape",
C.Reset + "Sneaky Assassins",
C.Reset + "Micro Battle",
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze",
C.Reset + "Wither Assault",
C.Reset + C.Bold + C.cGreen + "Evolution").setHideInfo(true));
}
private void createSuperSmashCycle()

View File

@ -159,6 +159,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
int hauntedChestsReceived = 0;
int hauntedChestsOpened = 0;
int trickOrTreatChestsReceived = 0;
int thankfulChestsReceived = 0;
for (CoinTransactionToken transaction : donor.getCoinTransactions())
{
@ -269,6 +270,17 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
trickOrTreatChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Thankful Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
thankfulChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
thankfulChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Valentines Gift"))
{
@ -339,6 +351,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
caller.sendMessage(C.cBlue + "Haunted Chests Received: " + C.cYellow + hauntedChestsReceived);
caller.sendMessage(C.cBlue + "Haunted Chests Opened: " + C.cYellow + hauntedChestsOpened);
caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived);
caller.sendMessage(C.cBlue + "Thankful Chests Received: " + C.cYellow + thankfulChestsReceived);
caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived);
caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min) Received: " + C.cYellow + runeAmplifier20);
caller.sendMessage(C.cBlue + "Rune Amplifiers (60 min) Received: " + C.cYellow + runeAmplifier60);

View File

@ -24,6 +24,7 @@ import mineplex.staffServer.salespackage.salespackages.DefaultRank;
import mineplex.staffServer.salespackage.salespackages.FreedomChest;
import mineplex.staffServer.salespackage.salespackages.HauntedChest;
import mineplex.staffServer.salespackage.salespackages.IlluminatedChest;
import mineplex.staffServer.salespackage.salespackages.LifetimeEternal;
import mineplex.staffServer.salespackage.salespackages.LifetimeHero;
import mineplex.staffServer.salespackage.salespackages.LifetimeLegend;
import mineplex.staffServer.salespackage.salespackages.LifetimeTitan;
@ -35,6 +36,7 @@ import mineplex.staffServer.salespackage.salespackages.Pet;
import mineplex.staffServer.salespackage.salespackages.PowerPlayClub;
import mineplex.staffServer.salespackage.salespackages.RuneAmplifier;
import mineplex.staffServer.salespackage.salespackages.SalesPackageBase;
import mineplex.staffServer.salespackage.salespackages.ThankfulChest;
import mineplex.staffServer.salespackage.salespackages.TrickOrTreatChest;
public class SalesPackageManager extends MiniPlugin
@ -72,6 +74,7 @@ public class SalesPackageManager extends MiniPlugin
AddSalesPackage(new LifetimeHero(this));
AddSalesPackage(new LifetimeLegend(this));
AddSalesPackage(new LifetimeTitan(this));
AddSalesPackage(new LifetimeEternal(this));
//AddSalesPackage(new GemHunter(this, 4));
//AddSalesPackage(new GemHunter(this, 8));
AddSalesPackage(new ApplyKits(this));
@ -92,6 +95,7 @@ public class SalesPackageManager extends MiniPlugin
AddSalesPackage(new OmegaChest(this));
AddSalesPackage(new HauntedChest(this));
AddSalesPackage(new TrickOrTreatChest(this));
AddSalesPackage(new ThankfulChest(this));
for (PetType petType : PetType.values())
{

View File

@ -0,0 +1,33 @@
package mineplex.staffServer.salespackage.command;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.staffServer.salespackage.SalesPackageManager;
public class LifetimeEternalCommand extends CommandBase<SalesPackageManager>
{
public LifetimeEternalCommand(SalesPackageManager plugin)
{
super(plugin, Rank.MODERATOR, "lifetimeeternal");
}
@Override
public void Execute(Player caller, String[] args)
{
resetCommandCharge(caller);
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ETERNAL true"));
resetCommandCharge(caller);
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 2 Item Mythical Chest"));
resetCommandCharge(caller);
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 2 Item Illuminated Chest"));
resetCommandCharge(caller);
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 1 Item Omega Chest"));
}
}

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