Website Link Reward (#645)
This commit is contained in:
parent
805baec25e
commit
4aeed642b3
@ -10,9 +10,8 @@ import org.bukkit.Location;
|
|||||||
|
|
||||||
public class DataLocationMap
|
public class DataLocationMap
|
||||||
{
|
{
|
||||||
private EnumMap<DyeColor, List<Location>> _goldDataMap;
|
|
||||||
private EnumMap<DyeColor, List<Location>> _ironDataMap;
|
private final EnumMap<DyeColor, List<Location>> _goldDataMap, _ironDataMap, _spongeDataMap;
|
||||||
private EnumMap<DyeColor, List<Location>> _spongeDataMap;
|
|
||||||
|
|
||||||
public DataLocationMap()
|
public DataLocationMap()
|
||||||
{
|
{
|
||||||
@ -61,7 +60,8 @@ public class DataLocationMap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSpongeLocation(DyeColor color, Location location) {
|
public void addSpongeLocation(DyeColor color, Location location)
|
||||||
|
{
|
||||||
if (_spongeDataMap.containsKey(color))
|
if (_spongeDataMap.containsKey(color))
|
||||||
{
|
{
|
||||||
_spongeDataMap.get(color).add(location);
|
_spongeDataMap.get(color).add(location);
|
||||||
@ -79,5 +79,4 @@ public class DataLocationMap
|
|||||||
List<Location> list = _spongeDataMap.get(color);
|
List<Location> list = _spongeDataMap.get(color);
|
||||||
return list == null ? Collections.emptyList() : list;
|
return list == null ? Collections.emptyList() : list;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -322,6 +322,7 @@ import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames;
|
|||||||
import mineplex.core.gadget.gadgets.wineffect.WinEffectHalloween;
|
import mineplex.core.gadget.gadgets.wineffect.WinEffectHalloween;
|
||||||
import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap;
|
import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap;
|
||||||
import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike;
|
import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike;
|
||||||
|
import mineplex.core.gadget.gadgets.wineffect.WinEffectLogo;
|
||||||
import mineplex.core.gadget.gadgets.wineffect.WinEffectLoveIsABattlefield;
|
import mineplex.core.gadget.gadgets.wineffect.WinEffectLoveIsABattlefield;
|
||||||
import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan;
|
import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan;
|
||||||
import mineplex.core.gadget.gadgets.wineffect.WinEffectPartyAnimal;
|
import mineplex.core.gadget.gadgets.wineffect.WinEffectPartyAnimal;
|
||||||
@ -818,6 +819,7 @@ public class GadgetManager extends MiniPlugin
|
|||||||
|
|
||||||
//Win Effects
|
//Win Effects
|
||||||
addGadget(new WinEffectPodium(this));
|
addGadget(new WinEffectPodium(this));
|
||||||
|
addGadget(new WinEffectLogo(this));
|
||||||
addGadget(new WinEffectMrPunchMan(this));
|
addGadget(new WinEffectMrPunchMan(this));
|
||||||
addGadget(new WinEffectFlames(this));
|
addGadget(new WinEffectFlames(this));
|
||||||
addGadget(new WinEffectSnowTrails(this));
|
addGadget(new WinEffectSnowTrails(this));
|
||||||
|
@ -129,7 +129,7 @@ public class WinEffectLavaTrap extends WinEffectGadget
|
|||||||
getBaseLocation().getWorld().playSound(getBaseLocation(), Sound.DIG_STONE, 1, 1.5f);
|
getBaseLocation().getWorld().playSound(getBaseLocation(), Sound.DIG_STONE, 1, 1.5f);
|
||||||
getBaseLocation().getWorld().playSound(getBaseLocation(), Sound.DIG_STONE, 1, 0.5f);
|
getBaseLocation().getWorld().playSound(getBaseLocation(), Sound.DIG_STONE, 1, 0.5f);
|
||||||
|
|
||||||
pasteScematic("LavaTrapPodium-part-2");
|
pasteSchematic("LavaTrapPodium-part-2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,185 @@
|
|||||||
|
package mineplex.core.gadget.gadgets.wineffect;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.FireworkEffect;
|
||||||
|
import org.bukkit.FireworkEffect.Type;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
|
import mineplex.core.common.block.schematic.SchematicData;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilFirework;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilTextBottom;
|
||||||
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.WinEffectGadget;
|
||||||
|
import mineplex.core.gadget.util.CostConstants;
|
||||||
|
|
||||||
|
public class WinEffectLogo extends WinEffectGadget
|
||||||
|
{
|
||||||
|
|
||||||
|
private DisguisePlayer _npc;
|
||||||
|
private SchematicData _data;
|
||||||
|
private Set<Block> _logoBlocks;
|
||||||
|
|
||||||
|
public WinEffectLogo(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Mineplex Logo", new String[]
|
||||||
|
{
|
||||||
|
C.cGray + "Awaken this ancient Mineplex Logo.",
|
||||||
|
C.blankLine,
|
||||||
|
C.cBlue + "Unlocked by linking your Mineplex",
|
||||||
|
C.cBlue + "forum account in-game",
|
||||||
|
}, CostConstants.NO_LORE, Material.WOOL, (byte) 1);
|
||||||
|
|
||||||
|
_schematicName = "LogoEffect";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void play()
|
||||||
|
{
|
||||||
|
Location location = getBaseLocation();
|
||||||
|
location.setYaw(180);
|
||||||
|
BlockRestore restore = Manager.getBlockRestore();
|
||||||
|
|
||||||
|
Manager.runSyncLater(() ->
|
||||||
|
{
|
||||||
|
_npc = getNPC(getPlayer(), location, true);
|
||||||
|
_logoBlocks.forEach(restore::restore);
|
||||||
|
location.getWorld().playSound(location, Sound.EXPLODE, 2, 0.6F);
|
||||||
|
|
||||||
|
List<Location> corners = _data.getDataLocationMap().getIronLocations(DyeColor.YELLOW);
|
||||||
|
Location start = corners.get(0), end = corners.get(1);
|
||||||
|
Vector direction = location.getDirection();
|
||||||
|
|
||||||
|
for (int i = 0; i < 14; i++)
|
||||||
|
{
|
||||||
|
Location fallingLocation = start.clone();
|
||||||
|
fallingLocation.setX(UtilMath.rRange(end.getBlockX(), start.getBlockX()));
|
||||||
|
fallingLocation.setY(UtilMath.rRange(start.getBlockY() + 2, end.getBlockY()));
|
||||||
|
|
||||||
|
FallingBlock block = start.getWorld().spawnFallingBlock(fallingLocation, Material.STONE, (byte) 0);
|
||||||
|
block.setDropItem(false);
|
||||||
|
block.setHurtEntities(false);
|
||||||
|
block.setVelocity(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, getBaseLocation().add(3, 8, 0), 4, 4, 0, 0, 10, ViewDist.NORMAL);
|
||||||
|
|
||||||
|
Manager.runSyncTimer(new BukkitRunnable()
|
||||||
|
{
|
||||||
|
int x = start.getBlockX();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!isRunning())
|
||||||
|
{
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i % 3 == 0)
|
||||||
|
{
|
||||||
|
UtilFirework.playFirework(UtilAlg.getRandomLocation(getBaseLocation().add(0, 13, 0), 10, 3, 10), FireworkEffect.builder()
|
||||||
|
.with(Type.BALL)
|
||||||
|
.withColor(Color.ORANGE)
|
||||||
|
.withFade(Color.BLACK)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
Entity entity = _npc.getEntity().getBukkitEntity();
|
||||||
|
_npc.sendHit();
|
||||||
|
|
||||||
|
if (UtilEnt.isGrounded(entity))
|
||||||
|
{
|
||||||
|
entity.setVelocity(new Vector(0, 0.42, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Block block : _logoBlocks)
|
||||||
|
{
|
||||||
|
if (block.getType() == Material.WOOL || block.getLocation().getBlockX() != x)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
restore.add(block, block.getTypeId(), (byte) 0, 240);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--x < end.getBlockX())
|
||||||
|
{
|
||||||
|
x = start.getBlockX();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i % 10 == 0)
|
||||||
|
{
|
||||||
|
UtilTextBottom.display(C.cGray + "Unlock " + C.cYellowB + "THIS" + C.cGray + " Win Effect by signing up on " + C.cGoldB + "MINEPLEX.COM", UtilServer.getPlayers());
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}, 10, 3);
|
||||||
|
}, 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildWinnerRoom()
|
||||||
|
{
|
||||||
|
_data = pasteSchematic(_schematicName);
|
||||||
|
|
||||||
|
List<Location> corners = _data.getDataLocationMap().getIronLocations(DyeColor.YELLOW);
|
||||||
|
corners.sort((o1, o2) -> o2.getBlockX() - o1.getBlockX());
|
||||||
|
|
||||||
|
BlockRestore restore = Manager.getBlockRestore();
|
||||||
|
_logoBlocks = new HashSet<>();
|
||||||
|
|
||||||
|
for (Block block : UtilBlock.getInBoundingBox(corners.get(0), corners.get(1)))
|
||||||
|
{
|
||||||
|
Material type = block.getType();
|
||||||
|
|
||||||
|
if (type == Material.WOOL || type == Material.STAINED_CLAY || type == Material.STAINED_GLASS)
|
||||||
|
{
|
||||||
|
restore.add(block, Material.STONE.getId(), (byte) 0, Integer.MAX_VALUE);
|
||||||
|
_logoBlocks.add(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teleport()
|
||||||
|
{
|
||||||
|
teleport(_data.getDataLocationMap().getGoldLocations(DyeColor.GREEN).get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish()
|
||||||
|
{
|
||||||
|
Manager.getDisguiseManager().undisguise(_npc);
|
||||||
|
_npc = null;
|
||||||
|
_data = null;
|
||||||
|
_logoBlocks.clear();
|
||||||
|
_logoBlocks = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -30,6 +30,7 @@ import com.mojang.authlib.GameProfile;
|
|||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.account.permissions.PermissionGroup;
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.common.block.schematic.Schematic;
|
import mineplex.core.common.block.schematic.Schematic;
|
||||||
|
import mineplex.core.common.block.schematic.SchematicData;
|
||||||
import mineplex.core.common.block.schematic.UtilSchematic;
|
import mineplex.core.common.block.schematic.UtilSchematic;
|
||||||
import mineplex.core.common.skin.SkinData;
|
import mineplex.core.common.skin.SkinData;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -317,7 +318,7 @@ public abstract class WinEffectGadget extends Gadget
|
|||||||
*/
|
*/
|
||||||
public void buildWinnerRoom()
|
public void buildWinnerRoom()
|
||||||
{
|
{
|
||||||
pasteScematic(_schematicName);
|
pasteSchematic(_schematicName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -390,14 +391,18 @@ public abstract class WinEffectGadget extends Gadget
|
|||||||
* in the server root directory
|
* in the server root directory
|
||||||
* @return Returns the schematic after pasting it. Will return <code>null</code> if any errors ocured.
|
* @return Returns the schematic after pasting it. Will return <code>null</code> if any errors ocured.
|
||||||
*/
|
*/
|
||||||
public Schematic pasteScematic(String schematicName)
|
public SchematicData pasteSchematic(String schematicName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + schematicName + ".schematic"));
|
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + schematicName + ".schematic"));
|
||||||
|
|
||||||
if (schematic != null)
|
if (schematic != null)
|
||||||
schematic.paste(getBaseLocation(), false, true);
|
{
|
||||||
return schematic;
|
return schematic.paste(getBaseLocation(), false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@ import mineplex.core.titles.tracks.award.FiveYearTrack;
|
|||||||
import mineplex.core.titles.tracks.award.MapSub2018Track;
|
import mineplex.core.titles.tracks.award.MapSub2018Track;
|
||||||
import mineplex.core.titles.tracks.award.Minestrike2017Track;
|
import mineplex.core.titles.tracks.award.Minestrike2017Track;
|
||||||
import mineplex.core.titles.tracks.award.NewHub2018Track;
|
import mineplex.core.titles.tracks.award.NewHub2018Track;
|
||||||
|
import mineplex.core.titles.tracks.award.NewWebsiteTrack;
|
||||||
import mineplex.core.titles.tracks.custom.DongerTrack;
|
import mineplex.core.titles.tracks.custom.DongerTrack;
|
||||||
import mineplex.core.titles.tracks.custom.EarlyBirdTrack;
|
import mineplex.core.titles.tracks.custom.EarlyBirdTrack;
|
||||||
import mineplex.core.titles.tracks.custom.HappyGaryTrack;
|
import mineplex.core.titles.tracks.custom.HappyGaryTrack;
|
||||||
@ -133,6 +134,7 @@ public class TrackManager extends MiniPlugin
|
|||||||
registerTrack(new NewHub2018Track());
|
registerTrack(new NewHub2018Track());
|
||||||
registerTrack(new MapSub2018Track());
|
registerTrack(new MapSub2018Track());
|
||||||
registerTrack(new FiveYearTrack());
|
registerTrack(new FiveYearTrack());
|
||||||
|
registerTrack(new NewWebsiteTrack());
|
||||||
|
|
||||||
// Staff tracks
|
// Staff tracks
|
||||||
registerTrack(new BuilderTrack());
|
registerTrack(new BuilderTrack());
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package mineplex.core.titles.tracks.award;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
import mineplex.core.titles.tracks.ItemizedTrack;
|
||||||
|
import mineplex.core.titles.tracks.TrackFormat;
|
||||||
|
import mineplex.core.titles.tracks.TrackTier;
|
||||||
|
|
||||||
|
public class NewWebsiteTrack extends ItemizedTrack
|
||||||
|
{
|
||||||
|
|
||||||
|
public NewWebsiteTrack()
|
||||||
|
{
|
||||||
|
super(
|
||||||
|
"new-website",
|
||||||
|
ChatColor.GOLD,
|
||||||
|
"Verified",
|
||||||
|
"Verified Player",
|
||||||
|
"This track is awarded to players who have linked their Mineplex forum account in-game.",
|
||||||
|
true);
|
||||||
|
|
||||||
|
getRequirements()
|
||||||
|
.addTier(new TrackTier(
|
||||||
|
"Verified " + ChatColor.WHITE + ChatColor.BOLD + "✓",
|
||||||
|
null,
|
||||||
|
this::owns,
|
||||||
|
new TrackFormat(ChatColor.GOLD, ChatColor.YELLOW)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,6 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.Authenticator;
|
import java.net.Authenticator;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -29,7 +28,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -37,21 +35,32 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.MiniDbClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||||
import mineplex.core.account.event.GroupAddEvent;
|
import mineplex.core.account.event.GroupAddEvent;
|
||||||
import mineplex.core.account.event.GroupRemoveEvent;
|
import mineplex.core.account.event.GroupRemoveEvent;
|
||||||
import mineplex.core.account.event.PrimaryGroupUpdateEvent;
|
import mineplex.core.account.event.PrimaryGroupUpdateEvent;
|
||||||
import mineplex.core.account.permissions.Permission;
|
import mineplex.core.account.permissions.Permission;
|
||||||
import mineplex.core.account.permissions.PermissionGroup;
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.gadgets.wineffect.WinEffectLogo;
|
||||||
import mineplex.core.powerplayclub.PPCDataRequestEvent;
|
import mineplex.core.powerplayclub.PPCDataRequestEvent;
|
||||||
import mineplex.core.powerplayclub.PowerPlayData;
|
import mineplex.core.powerplayclub.PowerPlayData;
|
||||||
import mineplex.core.powerplayclub.SubscriptionAddEvent;
|
import mineplex.core.powerplayclub.SubscriptionAddEvent;
|
||||||
|
import mineplex.core.server.util.TransactionResponse;
|
||||||
|
import mineplex.core.titles.tracks.Track;
|
||||||
|
import mineplex.core.titles.tracks.TrackManager;
|
||||||
|
import mineplex.core.titles.tracks.TrackManager.TrackGiveResult;
|
||||||
|
import mineplex.core.titles.tracks.award.NewWebsiteTrack;
|
||||||
import mineplex.serverdata.database.DBPool;
|
import mineplex.serverdata.database.DBPool;
|
||||||
|
|
||||||
|
@ReflectivelyCreateMiniPlugin
|
||||||
public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
||||||
{
|
{
|
||||||
public enum Perm implements Permission
|
public enum Perm implements Permission
|
||||||
@ -60,15 +69,15 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
UNLINK_COMMAND,
|
UNLINK_COMMAND,
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JsonParser PARSER = new JsonParser();
|
private static final JsonParser PARSER = new JsonParser();
|
||||||
private final String API_URL = "https://xen.mineplex.com/api.php";
|
private static final String API_URL = "https://xen.mineplex.com/api.php";
|
||||||
private final String API_KEY = "dd412425-edb0-477c-abee-2d0b507c59ef";
|
private static final String API_KEY = "dd412425-edb0-477c-abee-2d0b507c59ef";
|
||||||
private final int POWER_PLAY_TAG_ID = 17;
|
private static final int POWER_PLAY_TAG_ID = 17;
|
||||||
private final int LINKED_TAG_ID = 91;
|
private static final int LINKED_TAG_ID = 91;
|
||||||
|
|
||||||
public WebsiteLinkManager(JavaPlugin plugin, CoreClientManager clientManager)
|
private WebsiteLinkManager()
|
||||||
{
|
{
|
||||||
super("Website Link", plugin, clientManager);
|
super("Website Link");
|
||||||
|
|
||||||
addCommand(new LinkCommand(this));
|
addCommand(new LinkCommand(this));
|
||||||
addCommand(new UnlinkCommand(this));
|
addCommand(new UnlinkCommand(this));
|
||||||
@ -242,13 +251,13 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
adding.add(91);
|
adding.add(91);
|
||||||
if (group.getForumId() != -1)
|
if (group.getForumId() != -1)
|
||||||
{
|
{
|
||||||
adding.add(Integer.valueOf(group.getForumId()));
|
adding.add(group.getForumId());
|
||||||
}
|
}
|
||||||
for (PermissionGroup addit : additional)
|
for (PermissionGroup addit : additional)
|
||||||
{
|
{
|
||||||
if (addit.getForumId() != -1)
|
if (addit.getForumId() != -1)
|
||||||
{
|
{
|
||||||
adding.add(Integer.valueOf(addit.getForumId()));
|
adding.add(addit.getForumId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (powerPlay)
|
if (powerPlay)
|
||||||
@ -268,9 +277,49 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
UtilPlayer.message(player, F.main(getName(), "You have successfully linked your account!"));
|
UtilPlayer.message(player, F.main(getName(), "You have successfully linked your account!"));
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
{
|
{
|
||||||
Get(player).LinkedForumId = data.user_id;
|
ForumUserData userData = Get(player);
|
||||||
Get(player).LastSyncedPowerPlayStatus = powerPlay;
|
|
||||||
Get(player).Linked = true;
|
userData.LinkedForumId = data.user_id;
|
||||||
|
userData.LastSyncedPowerPlayStatus = powerPlay;
|
||||||
|
userData.Linked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackManager trackManager = Managers.get(TrackManager.class);
|
||||||
|
GadgetManager gadgetManager = Managers.get(GadgetManager.class);
|
||||||
|
DonationManager donationManager = Managers.get(DonationManager.class);
|
||||||
|
|
||||||
|
if (trackManager != null)
|
||||||
|
{
|
||||||
|
Track track = trackManager.getTrack(NewWebsiteTrack.class);
|
||||||
|
|
||||||
|
trackManager.unlockTrack(player, track, result ->
|
||||||
|
{
|
||||||
|
if (result == TrackGiveResult.SUCCESS)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main(getName(), "You unlocked the " + F.name(track.getLongName()) + " title."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main(getName(), "Was unable to reward you the " + F.name(track.getLongName()) + " title."));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gadgetManager != null && donationManager != null)
|
||||||
|
{
|
||||||
|
String gadget = gadgetManager.getGadget(WinEffectLogo.class).getName();
|
||||||
|
|
||||||
|
donationManager.purchaseUnknownSalesPackage(player, gadgetManager.getGadget(WinEffectLogo.class).getName(), GlobalCurrency.TREASURE_SHARD, 0, true, response ->
|
||||||
|
{
|
||||||
|
if (response == TransactionResponse.Success)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main(getName(), "You unlocked the " + F.name(gadget) + " Win Effect."));
|
||||||
|
}
|
||||||
|
else if (response != TransactionResponse.AlreadyOwns)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main(getName(), "Was unable to reward you the " + F.name(gadget) + " Win Effect."));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, true, () -> UtilPlayer.message(player, F.main(getName(), "The link failed! Please try again!")), true);
|
}, true, () -> UtilPlayer.message(player, F.main(getName(), "The link failed! Please try again!")), true);
|
||||||
});
|
});
|
||||||
@ -316,33 +365,33 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String callBase = "action=editUser&user=" + makeUsernameURL(data.username);
|
String callBase = "action=editUser&user=" + makeUsernameURL(data.username);
|
||||||
String groups = "";
|
StringBuilder groups = new StringBuilder();
|
||||||
for (int groupId : data.secondary_group_ids)
|
for (int groupId : data.secondary_group_ids)
|
||||||
{
|
{
|
||||||
if (!removing.contains(groupId) && !adding.contains(groupId))
|
if (!removing.contains(groupId) && !adding.contains(groupId))
|
||||||
{
|
{
|
||||||
groups += ("," + groupId);
|
groups.append(",").append(groupId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Integer groupId : adding)
|
for (Integer groupId : adding)
|
||||||
{
|
{
|
||||||
groups += ("," + groupId);
|
groups.append(",").append(groupId);
|
||||||
}
|
}
|
||||||
if (!groups.isEmpty())
|
if (groups.length() > 0)
|
||||||
{
|
{
|
||||||
groups = groups.substring(1);
|
groups = new StringBuilder(groups.substring(1));
|
||||||
}
|
}
|
||||||
final String addGroups = groups;
|
final String addGroups = groups.toString();
|
||||||
groups = "";
|
groups = new StringBuilder();
|
||||||
for (int groupId : data.secondary_group_ids)
|
for (int groupId : data.secondary_group_ids)
|
||||||
{
|
{
|
||||||
groups += ("," + groupId);
|
groups.append(",").append(groupId);
|
||||||
}
|
}
|
||||||
if (!groups.isEmpty())
|
if (groups.length() > 0)
|
||||||
{
|
{
|
||||||
groups = groups.substring(1);
|
groups = new StringBuilder(groups.substring(1));
|
||||||
}
|
}
|
||||||
final String remGroups = groups;
|
final String remGroups = groups.toString();
|
||||||
if (!remGroups.isEmpty())
|
if (!remGroups.isEmpty())
|
||||||
{
|
{
|
||||||
doAPICall(callBase + "&remove_groups=" + remGroups, err ->
|
doAPICall(callBase + "&remove_groups=" + remGroups, err ->
|
||||||
@ -481,11 +530,11 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
URL call = new URL(API_URL + "?hash=" + API_KEY + "&action=getUser&value=" + userId);
|
URL call = new URL(API_URL + "?hash=" + API_KEY + "&action=getUser&value=" + userId);
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(call.openStream()));
|
BufferedReader br = new BufferedReader(new InputStreamReader(call.openStream()));
|
||||||
br.lines().forEach(line -> result.append(line));
|
br.lines().forEach(result::append);
|
||||||
|
|
||||||
String json = result.toString().trim();
|
String json = result.toString().trim();
|
||||||
|
|
||||||
JsonObject response = null;
|
JsonObject response;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = PARSER.parse(json).getAsJsonObject();
|
response = PARSER.parse(json).getAsJsonObject();
|
||||||
@ -534,11 +583,6 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MalformedURLException e)
|
|
||||||
{
|
|
||||||
callback.accept(null);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
callback.accept(null);
|
callback.accept(null);
|
||||||
@ -623,12 +667,12 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
sb.insert(0, "0");
|
sb.insert(0, "0");
|
||||||
}
|
}
|
||||||
String reverse = sb.reverse().toString();
|
String reverse = sb.reverse().toString();
|
||||||
Integer test = Integer.parseInt(reverse + reverse + reverse);
|
int test = Integer.parseInt(reverse + reverse + reverse);
|
||||||
test += offset;
|
test += offset;
|
||||||
|
|
||||||
Integer input = Integer.parseInt(given);
|
int input = Integer.parseInt(given);
|
||||||
|
|
||||||
Integer abs = Math.abs(test - input);
|
int abs = Math.abs(test - input);
|
||||||
|
|
||||||
// Bukkit.broadcastMessage("REVERSE: " + reverse);
|
// Bukkit.broadcastMessage("REVERSE: " + reverse);
|
||||||
// Bukkit.broadcastMessage("TEST: " + test);
|
// Bukkit.broadcastMessage("TEST: " + test);
|
||||||
@ -853,7 +897,7 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
ResultSet rs = c.prepareStatement("SELECT userId FROM forumLink WHERE accountId=" + event.getAccountId() + ";").executeQuery();
|
ResultSet rs = c.prepareStatement("SELECT userId FROM forumLink WHERE accountId=" + event.getAccountId() + ";").executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
Integer userId = rs.getInt(1);
|
int userId = rs.getInt(1);
|
||||||
List<Integer> add = new ArrayList<>();
|
List<Integer> add = new ArrayList<>();
|
||||||
add.add(17);
|
add.add(17);
|
||||||
refreshSiteTags(userId, new ArrayList<>(), add, false, () ->
|
refreshSiteTags(userId, new ArrayList<>(), add, false, () ->
|
||||||
@ -885,7 +929,7 @@ public class WebsiteLinkManager extends MiniDbClientPlugin<ForumUserData>
|
|||||||
{
|
{
|
||||||
if (event.getPlayer().isOnline())
|
if (event.getPlayer().isOnline())
|
||||||
{
|
{
|
||||||
boolean ppc = false;
|
boolean ppc;
|
||||||
PowerPlayData d = UtilServer.CallEvent(new PPCDataRequestEvent(event.getPlayer())).getData();
|
PowerPlayData d = UtilServer.CallEvent(new PPCDataRequestEvent(event.getPlayer())).getData();
|
||||||
if (d != null)
|
if (d != null)
|
||||||
{
|
{
|
||||||
|
@ -180,7 +180,7 @@ public class ClansHub extends JavaPlugin
|
|||||||
require(TrackManager.class);
|
require(TrackManager.class);
|
||||||
require(Titles.class);
|
require(Titles.class);
|
||||||
require(TwoFactorAuth.class);
|
require(TwoFactorAuth.class);
|
||||||
new WebsiteLinkManager(this, clientManager);
|
require(WebsiteLinkManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -202,7 +202,7 @@ public class Hub extends JavaPlugin implements IRelation
|
|||||||
require(Titles.class);
|
require(Titles.class);
|
||||||
require(TwoFactorAuth.class);
|
require(TwoFactorAuth.class);
|
||||||
require(TeamspeakManager.class);
|
require(TeamspeakManager.class);
|
||||||
new WebsiteLinkManager(this, clientManager);
|
require(WebsiteLinkManager.class);
|
||||||
require(TwitchIntegrationFix.class);
|
require(TwitchIntegrationFix.class);
|
||||||
require(SoundNotifier.class);
|
require(SoundNotifier.class);
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ public class Arcade extends JavaPlugin
|
|||||||
new FoodDupeFix(this);
|
new FoodDupeFix(this);
|
||||||
|
|
||||||
require(TwoFactorAuth.class);
|
require(TwoFactorAuth.class);
|
||||||
new WebsiteLinkManager(this, clientManager);
|
require(WebsiteLinkManager.class);
|
||||||
require(TwitchIntegrationFix.class);
|
require(TwitchIntegrationFix.class);
|
||||||
|
|
||||||
AprilFoolsManager.getInstance();
|
AprilFoolsManager.getInstance();
|
||||||
|
Loading…
Reference in New Issue
Block a user