Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
CoderTim 2014-08-23 16:00:26 -04:00
commit c89461628b
42 changed files with 1246 additions and 197 deletions

View File

@ -0,0 +1,118 @@
package mineplex.core.common.util;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
import java.util.UUID;
import java.util.logging.Level;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
public class ProfileLoader
{
private final String uuid;
private final String name;
private final String skinOwner;
public ProfileLoader(String uuid, String name)
{
this(uuid, name, name);
}
public ProfileLoader(String uuid, String name, String skinOwner)
{
this.uuid = uuid == null ? null : uuid.replaceAll("-", ""); // We add
// these
// later
String displayName = ChatColor.translateAlternateColorCodes('&', name);
this.name = ChatColor.stripColor(displayName);
this.skinOwner = skinOwner;
}
public GameProfile loadProfile()
{
UUID id = uuid == null ? parseUUID(getUUID(name)) : parseUUID(uuid);
GameProfile profile = new GameProfile(id, name);
addProperties(profile);
return profile;
}
private void addProperties(GameProfile profile)
{
String uuid = getUUID(skinOwner);
try
{
// Get the name from SwordPVP
URL url = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
URLConnection uc = url.openConnection();
uc.setUseCaches(false);
uc.setDefaultUseCaches(false);
uc.addRequestProperty("User-Agent", "Mozilla/5.0");
uc.addRequestProperty("Cache-Control", "no-cache, no-store, must-revalidate");
uc.addRequestProperty("Pragma", "no-cache");
// Parse it
String json = new Scanner(uc.getInputStream(), "UTF-8").useDelimiter("\\A").next();
JSONParser parser = new JSONParser();
Object obj = parser.parse(json);
JSONArray properties = (JSONArray) ((JSONObject) obj).get("properties");
for (int i = 0; i < properties.size(); i++)
{
try
{
JSONObject property = (JSONObject) properties.get(i);
String name = (String) property.get("name");
String value = (String) property.get("value");
String signature = property.containsKey("signature") ? (String) property.get("signature") : null;
if (signature != null)
{
profile.getProperties().put(name, new Property(name, value, signature));
}
else
{
profile.getProperties().put(name, new Property(value, name));
}
}
catch (Exception e)
{
Bukkit.getLogger().log(Level.WARNING, "Failed to apply auth property", e);
}
}
}
catch (Exception e)
{
; // Failed to load skin
}
}
@SuppressWarnings("deprecation")
private String getUUID(String name)
{
return Bukkit.getOfflinePlayer(name).getUniqueId().toString().replaceAll("-", "");
}
private UUID parseUUID(String uuidStr)
{
// Split uuid in to 5 components
String[] uuidComponents = new String[] { uuidStr.substring(0, 8), uuidStr.substring(8, 12),
uuidStr.substring(12, 16), uuidStr.substring(16, 20), uuidStr.substring(20, uuidStr.length()) };
// Combine components with a dash
StringBuilder builder = new StringBuilder();
for (String component : uuidComponents)
{
builder.append(component).append('-');
}
// Correct uuid length, remove last dash
builder.setLength(builder.length() - 1);
return UUID.fromString(builder.toString());
}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.achievement;
import org.bukkit.ChatColor;
public class AchivementData
{
private int _level;

View File

@ -1,7 +1,5 @@
package mineplex.core.disguise.disguises;
import java.util.UUID;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
@ -9,26 +7,23 @@ import net.minecraft.util.com.mojang.authlib.GameProfile;
public class DisguisePlayer extends DisguiseHuman
{
private String _name;
private GameProfile _profile;
public DisguisePlayer(org.bukkit.entity.Entity entity)
{
super(entity);
}
public DisguisePlayer(org.bukkit.entity.Entity entity, String name)
public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile)
{
this(entity);
setName(name);
setProfile(profile);
}
public void setName(String name)
public void setProfile(GameProfile profile)
{
if (name.length() > 16)
_name = name.substring(0, 16);
else
_name = name;
_profile = profile;
}
@Override
@ -36,7 +31,7 @@ public class DisguisePlayer extends DisguiseHuman
{
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
packet.a = Entity.getId();
packet.b = new GameProfile(UUID.randomUUID(), _name);
packet.b = _profile;
packet.c = MathHelper.floor(Entity.locX * 32.0D);
packet.d = MathHelper.floor(Entity.locY * 32.0D);
packet.e = MathHelper.floor(Entity.locZ * 32.0D);

View File

@ -14,7 +14,7 @@ public class DisguiseSheep extends DisguiseAnimal
public boolean isSheared()
{
return (DataWatcher.getByte(16) & 0x10) != 0;
return (DataWatcher.getByte(16) & 16) != 0;
}
public void setSheared(boolean sheared)
@ -22,14 +22,14 @@ public class DisguiseSheep extends DisguiseAnimal
byte b0 = DataWatcher.getByte(16);
if (sheared)
DataWatcher.watch(16, Byte.valueOf((byte)(b0 | 0x10)));
DataWatcher.watch(16, Byte.valueOf((byte)(b0 | 16)));
else
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & 0xFFFFFFEF)));
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & -17)));
}
public int getColor()
{
return DataWatcher.getByte(16) & 0xF;
return DataWatcher.getByte(16) & 15;
}
@SuppressWarnings("deprecation")
@ -37,6 +37,6 @@ public class DisguiseSheep extends DisguiseAnimal
{
byte b0 = DataWatcher.getByte(16);
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & 0xF0 | color.getWoolData() & 0xF)));
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & 240 | color.getWoolData() & 15)));
}
}

View File

@ -7,6 +7,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -87,7 +88,9 @@ public class GadgetManager extends MiniPlugin
addGadget(new ItemTNT(this));
addGadget(new ItemFleshHook(this));
addGadget(new ItemMelonLauncher(this));
//addGadget(new ItemFootball(this));
//addGadget(new ItemDuelingSword(this));
// Morphs
addGadget(new MorphBlaze(this));
addGadget(new MorphPumpkinKing(this));
@ -97,13 +100,15 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphBat(this));
addGadget(new MorphBlock(this));
addGadget(new MorphVillager(this));
addGadget(new MorphCow(this));
addGadget(new MorphNotch(this));
// Particles
addGadget(new ParticleGreen(this));
addGadget(new ParticleFoot(this));
addGadget(new ParticleEnchant(this));
addGadget(new ParticleFireRings(this));
addGadget(new ParticleRain(this));
addGadget(new ParticleRain(this));
addGadget(new ParticleHelix(this));
// Music
@ -319,6 +324,14 @@ public class GadgetManager extends MiniPlugin
_playerActiveGadgetMap.remove(event.getPlayer());
}
@EventHandler
public void death(PlayerDeathEvent event)
{
_lastMove.remove(event.getEntity());
_playerActiveGadgetMap.remove(event.getEntity());
}
public void setActive(Player player, Gadget gadget)
{

View File

@ -0,0 +1,66 @@
package mineplex.core.gadget.gadgets;
import java.util.HashSet;
import org.bukkit.Material;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ItemGadget;
public class ItemDuelingSword extends ItemGadget
{
public ItemDuelingSword(GadgetManager manager)
{
super(manager, "Dueling Sword", new String[]
{
C.cWhite + "While active, you are able to fight",
C.cWhite + "against other people who are also",
C.cWhite + "wielding a dueling sword.",
},
-1,
Material.WOOD_SWORD, (byte)3,
1000, new Ammo("Dueling Sword", "10 Swords", Material.WOOD_SWORD, (byte)0, new String[] { C.cWhite + "10 Swords to duel with" }, 1000, 10));
}
@Override
public void ActivateCustom(Player player)
{
ItemStack stack = new ItemStack(Material.GOLD_SWORD);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName("Dueling Sword");
stack.setItemMeta(meta);
player.getInventory().setItem(Manager.getActiveItemSlot(), stack);
//Inform
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent event)
{
if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
return;
Player damager = (Player)event.getDamager();
Player damagee = (Player)event.getEntity();
if (!UtilGear.isMat(damager.getItemInHand(), Material.GOLD_SWORD) || !UtilGear.isMat(damagee.getItemInHand(), Material.GOLD_SWORD))
return;
event.setCancelled(false);
event.setDamage(4);
}
}

View File

@ -0,0 +1,125 @@
package mineplex.core.gadget.gadgets;
import java.util.HashSet;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFallingSand;
import org.bukkit.entity.Bat;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class ItemFootball extends ItemGadget
{
private HashSet<Bat> _active = new HashSet<Bat>();
public ItemFootball(GadgetManager manager)
{
super(manager, "Football", new String[]
{
C.cWhite + "An amazing souvenier from the",
C.cWhite + "Mineplex World Cup in 2053!",
},
-1,
Material.CLAY_BALL, (byte)3,
1000, new Ammo("Melon Launcher", "10 Footballs", Material.CLAY_BALL, (byte)0, new String[] { C.cWhite + "10 Footballs to play with" }, 1000, 10));
}
@Override
public void ActivateCustom(Player player)
{
//Action
FallingBlock ball = player.getWorld().spawnFallingBlock(player.getLocation().add(0, 1, 0), Material.SKULL, (byte) 3);
Bat bat = player.getWorld().spawn(player.getLocation(), Bat.class);
UtilEnt.Vegetate(bat);
UtilEnt.ghost(bat, true, true);
UtilEnt.silence(bat, true);
bat.setPassenger(ball);
_active.add(bat);
//Inform
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
}
@EventHandler
public void Collide(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Bat ball : _active)
{
if (ball.getPassenger() != null)
{
((CraftFallingSand)ball.getPassenger()).getHandle().ticksLived = 1;
ball.getPassenger().setTicksLived(1);
}
for (Player other : UtilServer.getPlayers())
{
if (UtilMath.offset(ball, other) > 1.5)
continue;
if (!Recharge.Instance.use(other, GetName() + " Bump", 200, false, false))
continue;
double power = 0.4;
if (other.isSprinting())
power = 0.7;
//Velocity
UtilAction.velocity(ball, UtilAlg.getTrajectory2d(other, ball), power, false, 0, 0, 0, false);
other.getWorld().playSound(other.getLocation(), Sound.ITEM_PICKUP, 0.2f, 0.2f);
}
}
}
@EventHandler
public void Snort(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!UtilEvent.isAction(event, ActionType.L))
return;
for (Bat ball : _active)
{
if (UtilMath.offset(ball, player) > 2)
continue;
if (!Recharge.Instance.use(player, GetName() + " Kick", 1000, false, false))
return;
Recharge.Instance.useForce(player, GetName() + " Bump", 1000);
//Velocity
UtilAction.velocity(ball, UtilAlg.getTrajectory2d(player, ball), 2, false, 0, 0, 0, false);
player.getWorld().playSound(player.getLocation(), Sound.ITEM_PICKUP, 1f, 0.1f);
}
}
}

View File

@ -33,7 +33,7 @@ public class MorphBlock extends MorphGadget
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Change Block",
C.cYellow + "Stay Still" + C.cGray + " to use " + C.cGreen + "Solidify",
},
40000,
30000,
ArmorSlot.Helmet, Material.EMERALD_BLOCK, (byte)0);
}

View File

@ -0,0 +1,66 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguiseCow;
import mineplex.core.recharge.Recharge;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
public class MorphCow extends MorphGadget
{
public MorphCow(GadgetManager manager)
{
super(manager, "Cow Morph", new String[]
{
C.cWhite + "How now brown cow?",
" ",
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Moo",
},
6000,
ArmorSlot.Helmet, Material.LEATHER, (byte)0);
}
@Override
public void EnableCustom(final Player player)
{
this.ApplyArmor(player);
DisguiseCow disguise = new DisguiseCow(player);
disguise.SetName(player.getName(), Manager.getClientManager().Get(player).GetRank());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}
@Override
public void DisableCustom(Player player)
{
this.RemoveArmor(player);
Manager.getDisguiseManager().undisguise(player);
}
@EventHandler
public void Audio(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 2500, false, false))
return;
player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, 1f, 1f);
}
}

View File

@ -0,0 +1,70 @@
package mineplex.core.gadget.gadgets;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.ProfileLoader;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
public class MorphNotch extends MorphGadget
{
private GameProfile _notchProfile = null;
public MorphNotch(GadgetManager manager)
{
super(manager, "Notch", new String[]
{
" ",
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Enforce EULA",
},
50000,
ArmorSlot.Helmet, Material.SKULL_ITEM, (byte)3);
_notchProfile = new ProfileLoader(UUIDFetcher.getUUIDOf("Notch").toString(), "Notch").loadProfile();
}
@Override
public void EnableCustom(final Player player)
{
this.ApplyArmor(player);
DisguisePlayer disguise = new DisguisePlayer(player, _notchProfile);
Manager.getDisguiseManager().disguise(disguise);
}
@Override
public void DisableCustom(Player player)
{
this.RemoveArmor(player);
Manager.getDisguiseManager().undisguise(player);
}
@EventHandler
public void Audio(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 1500, false, false))
return;
player.sendMessage("You have enforced the EULA.");
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
@ -40,6 +41,8 @@ public class MorphPumpkinKing extends MorphGadget
disguise.SetCustomNameVisible(true);
disguise.SetSkeletonType(SkeletonType.WITHER);
Manager.getDisguiseManager().disguise(disguise);
player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{

View File

@ -1,46 +0,0 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseSnowman;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
public class MorphSnowman extends MorphGadget
{
public MorphSnowman(GadgetManager manager)
{
super(manager, "Snowmans Head", new String[]
{
C.cWhite + "Transforms the wearer into",
C.cWhite + "a Christmas Snowman!",
"",
C.cYellow + "Earned by defeating the Pumpkin King",
C.cYellow + "in the 2013 Christmas Chaos Event.",
},
-1,
ArmorSlot.Helmet, Material.SNOW_BLOCK, (byte)0);
}
@Override
public void EnableCustom(final Player player)
{
this.ApplyArmor(player);
DisguiseSnowman disguise = new DisguiseSnowman(player);
disguise.SetName(player.getName(), Manager.getClientManager().Get(player).GetRank());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}
@Override
public void DisableCustom(Player player)
{
this.RemoveArmor(player);
Manager.getDisguiseManager().undisguise(player);
}
}

View File

@ -26,7 +26,7 @@ public class MorphVillager extends MorphGadget
" ",
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "HURRR",
},
20000,
12000,
ArmorSlot.Helmet, Material.EMERALD, (byte)0);
}

View File

@ -9,7 +9,9 @@ import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
@ -113,6 +115,18 @@ public class MountManager extends MiniPlugin
mount.Disable(player);
}
@EventHandler
public void quit(PlayerQuitEvent event)
{
_playerActiveMountMap.remove(event.getPlayer());
}
@EventHandler
public void death(PlayerDeathEvent event)
{
_playerActiveMountMap.remove(event.getEntity());
}
public void setActive(Player player, Mount<?> mount)
{
_playerActiveMountMap.put(player, mount);

View File

@ -8,14 +8,18 @@ import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Player;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MountSheep extends HorseMount
{
@ -42,16 +46,8 @@ public class MountSheep extends HorseMount
Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
/*horse.setAdult();
horse.setAgeLock(true);
horse.setColor(_color);
horse.setStyle(_style);
horse.setVariant(_variant);
*/
horse.setOwner(player);
horse.setMaxDomestication(1);
//horse.setJumpStrength(_jump);
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
DisguiseSheep disguise = new DisguiseSheep(horse);
@ -66,4 +62,25 @@ public class MountSheep extends HorseMount
//Store
_active.put(player, horse);
}
@EventHandler
public void updateColor(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Horse horse : GetActive().values())
{
DisguiseBase base = Manager.getDisguiseManager().getDisguise(horse);
if (base == null || !(base instanceof DisguiseSheep))
continue;
DisguiseSheep sheep = (DisguiseSheep)base;
if (horse.getTicksLived() % 4 == 0) sheep.setColor(DyeColor.RED);
else if (horse.getTicksLived() % 4 == 1) sheep.setColor(DyeColor.YELLOW);
else if (horse.getTicksLived() % 4 == 2) sheep.setColor(DyeColor.GREEN);
else if (horse.getTicksLived() % 4 == 3) sheep.setColor(DyeColor.BLUE);
}
}
}

View File

@ -1,5 +1,7 @@
package mineplex.hub;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -130,6 +132,8 @@ public class Hub extends JavaPlugin implements IRelation
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
}
@Override

View File

@ -20,6 +20,7 @@ import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
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;
@ -55,14 +56,12 @@ import mineplex.core.common.util.UtilWorld;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSlime;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.logger.Logger;
import mineplex.core.mount.MountManager;
import mineplex.core.pet.PetManager;
import mineplex.core.portal.Portal;
@ -410,12 +409,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
}
}
@EventHandler
public void PlayerRespawn(PlayerRespawnEvent event)
{
event.setRespawnLocation(GetSpawn());
}
@EventHandler(priority = EventPriority.MONITOR)
public void OnChunkLoad(ChunkLoadEvent event)
{
@ -425,11 +418,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
{
if (((LivingEntity)entity).isCustomNameVisible() && ((LivingEntity)entity).getCustomName() != null)
{
if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Minekart"))
{
_disguiseManager.disguise(new DisguisePlayer(entity, ChatColor.YELLOW + "MineKart"));
}
else if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Block Hunt"))
if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Block Hunt"))
{
DisguiseSlime disguise = new DisguiseSlime(entity);
disguise.SetCustomNameVisible(true);
@ -475,79 +464,88 @@ public class HubManager extends MiniClientPlugin<HubClient>
else
event.getPlayer().setOp(false);
}
@EventHandler
public void PlayerRespawn(PlayerRespawnEvent event)
{
event.setRespawnLocation(GetSpawn().add(0, 10, 0));
}
@EventHandler(priority = EventPriority.LOW)
public void PlayerJoin(PlayerJoinEvent event)
{
try
Player player = event.getPlayer();
//Public Message
event.setJoinMessage(null);
//Teleport
player.teleport(GetSpawn().add(0, 10, 0));
//Survival
player.setGameMode(GameMode.SURVIVAL);
//Clear Inv
UtilInv.Clear(player);
//Allow Double Jump
player.setAllowFlight(true);
//Health
player.setHealth(20);
//Rules
player.getInventory().setItem(6, _ruleBook);
//Scoreboard
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
player.setScoreboard(board);
_scoreboards.put(player, board);
//Objective
Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy");
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
for (Rank rank : Rank.values())
{
final Player player = event.getPlayer();
if (rank != Rank.ALL)
board.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " ");
else
board.registerNewTeam(rank.Name).setPrefix("");
}
//Survival
player.setGameMode(GameMode.SURVIVAL);
for (Player otherPlayer : Bukkit.getOnlinePlayers())
{
if (_clientManager.Get(otherPlayer) == null)
continue;
//Public Message
event.setJoinMessage(null);
String rankName = _clientManager.Get(player).GetRank().Name;
String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name;
//Teleport
player.teleport(GetSpawn());
//Allow Double Jump
player.setAllowFlight(true);
UtilInv.Clear(player);
player.getInventory().setItem(6, _ruleBook);
//Scoreboard
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
player.setScoreboard(board);
_scoreboards.put(player, board);
//Objective
Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy");
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
for (Rank rank : Rank.values())
if (!_clientManager.Get(player).GetRank().Has(Rank.ULTRA) && _donationManager.Get(player.getName()).OwnsUltraPackage())
{
if (rank != Rank.ALL)
board.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " ");
else
board.registerNewTeam(rank.Name).setPrefix("");
rankName = Rank.ULTRA.Name;
}
for (Player otherPlayer : Bukkit.getOnlinePlayers())
if (!_clientManager.Get(otherPlayer).GetRank().Has(Rank.ULTRA) && _donationManager.Get(otherPlayer.getName()).OwnsUltraPackage())
{
if (_clientManager.Get(otherPlayer) == null)
continue;
String rankName = _clientManager.Get(player).GetRank().Name;
String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name;
if (!_clientManager.Get(player).GetRank().Has(Rank.ULTRA) && _donationManager.Get(player.getName()).OwnsUltraPackage())
{
rankName = Rank.ULTRA.Name;
}
if (!_clientManager.Get(otherPlayer).GetRank().Has(Rank.ULTRA) && _donationManager.Get(otherPlayer.getName()).OwnsUltraPackage())
{
otherRankName = Rank.ULTRA.Name;
}
//Add Other to Self
board.getTeam(otherRankName).addPlayer(otherPlayer);
//Add Self to Other
otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player);
otherRankName = Rank.ULTRA.Name;
}
//Add Other to Self
board.getTeam(otherRankName).addPlayer(otherPlayer);
//Add Self to Other
otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player);
}
catch (Exception ex)
{
Logger.Instance.log(ex);
System.out.println("[HubManager] Player Join exception");
throw ex;
}
}
@EventHandler
public void PlayerDeath(PlayerDeathEvent event)
{
//XXX make this work > event.setKeepInventory(true);
event.getDrops().clear();
}
@EventHandler
@ -658,13 +656,14 @@ public class HubManager extends MiniClientPlugin<HubClient>
@EventHandler
public void FoodHealthUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
{
player.setHealth(20);
player.setFoodLevel(20);
player.setExhaustion(0f);
player.setSaturation(3f);
}
}
@ -938,4 +937,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
{
}
}

View File

@ -89,7 +89,6 @@ public class ParkourManager extends MiniPlugin
}, 4000, new Location(Manager.GetSpawn().getWorld(), -93,67,38),
new Location(Manager.GetSpawn().getWorld(), -86,100,42), new Location(Manager.GetSpawn().getWorld(), -120,50,-17)));
/*
_parkour.add(new ParkourSnake("Snake Parkour", new String[]
{
"This parkour requires incredible timing",
@ -97,7 +96,7 @@ public class ParkourManager extends MiniPlugin
"by the devil as a cruel joke!"
}, 8000, new Location(Manager.GetSpawn().getWorld(), 22,70,-54),
new Location(Manager.GetSpawn().getWorld(), 28,-50,-88), new Location(Manager.GetSpawn().getWorld(), -24,90,-46)));
*/
_lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5,68,36.5);
_lavaParkourReturn.setYaw(90);

View File

@ -96,10 +96,10 @@ public class WorldManager extends MiniPlugin
Location loc = Manager.GetSpawn();
if (r > 0.75) loc.add(32, 0.5, 0);
else if (r > 0.5) loc.add(0, 0.5, 32);
else if (r > 0.25) loc.add(-32, 0.5, 0);
else loc.add(0, 0.5, -32);
if (r > 0.75) loc = new Location(Manager.GetSpawn().getWorld(), -9, 72, 42);
else if (r > 0.5) loc = new Location(Manager.GetSpawn().getWorld(), -36, 72, -28);
else if (r > 0.25) loc = new Location(Manager.GetSpawn().getWorld(), 31, 72, -34);
else loc = new Location(Manager.GetSpawn().getWorld(), 43, 72, 5);
//Spawn
if (Manager.Mode.equals("Halloween"))

View File

@ -63,6 +63,7 @@ import mineplex.serverdata.MinecraftServer;
public class ServerManager extends MiniPlugin
{
private static final Long FREE_PORTAL_TIMER = 30000L;
private static final Long BETA_PORTAL_TIMER = 600000L;
private CoreClientManager _clientManager;
private DonationManager _donationManager;
@ -81,7 +82,7 @@ public class ServerManager extends MiniPlugin
private NautHashMap<Vector, String> _serverPortalLocations = new NautHashMap<Vector, String>();
// Join Time for Free Players Timer
private NautHashMap<String, Long> _freeJoinTime = new NautHashMap<String, Long>();
private NautHashMap<String, Long> _joinTime = new NautHashMap<String, Long>();
private QueueShop _domShop;
private QuickShop _quickShop;
@ -141,7 +142,7 @@ public class ServerManager extends MiniPlugin
if (!Recharge.Instance.use(player, "Portal Server", 1000, false, false))
return;
long timeUntilPortal = getMillisecondsUntilPortal(player);
long timeUntilPortal = getMillisecondsUntilPortal(player, false);
if (!_hubManager.CanPortal(player) || timeUntilPortal > 0)
{
if (timeUntilPortal > 0)
@ -240,14 +241,14 @@ public class ServerManager extends MiniPlugin
if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ALL)
{
_freeJoinTime.put(event.getPlayer().getName(), System.currentTimeMillis());
_joinTime.put(event.getPlayer().getName(), System.currentTimeMillis());
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_freeJoinTime.remove(event.getPlayer().getName());
_joinTime.remove(event.getPlayer().getName());
}
@EventHandler(priority = EventPriority.LOWEST)
@ -263,19 +264,17 @@ public class ServerManager extends MiniPlugin
}
}
public Long getMillisecondsUntilPortal(Player player)
public Long getMillisecondsUntilPortal(Player player, boolean beta)
{
// Party party = _partyManager.GetParty(player);
long timeLeft = 0;
if (_freeJoinTime.containsKey(player.getName()))
if (_joinTime.containsKey(player.getName()))
{
timeLeft = (_freeJoinTime.get(player.getName()) - System.currentTimeMillis()) + FREE_PORTAL_TIMER;
timeLeft = (_joinTime.get(player.getName()) - System.currentTimeMillis()) + (beta ? BETA_PORTAL_TIMER : FREE_PORTAL_TIMER);
if (timeLeft <= 0)
{
_freeJoinTime.remove(player.getName());
timeLeft = 0;
}
}
// if (party != null)

View File

@ -78,18 +78,18 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
}
}
private void showClock(long milliseconds)
private void showClock(long milliseconds, boolean beta)
{
int seconds = (int) (milliseconds / 1000);
String timeLeft = UtilTime.convertString(milliseconds, 0, UtilTime.TimeUnit.SECONDS);
String timeLeft = UtilTime.convertString(milliseconds, 0, UtilTime.TimeUnit.FIT);
byte data = (byte) (milliseconds - (seconds * 1000) > 500 ? 15 : 14);
ShopItem item = new ShopItem(Material.WOOL, data, ChatColor.RESET + C.Bold + "Free Server Timer", null, new String[] {
ShopItem item = new ShopItem(Material.WOOL, data, ChatColor.RESET + C.Bold + (beta ? "Beta" : "Free") + " Server Timer", null, new String[] {
ChatColor.RESET + C.cGreen + timeLeft + " Remaining...",
ChatColor.RESET + "",
ChatColor.RESET + C.cYellow + "Free players must wait a short time",
ChatColor.RESET + C.cYellow + "to help lighten the load on our servers.",
ChatColor.RESET + C.cYellow + "Free players must wait a " + (beta ? "long" : "short") + " time",
ChatColor.RESET + C.cYellow + "to help lighten the load on our " + (beta ? "Beta" : "") + " servers.",
ChatColor.RESET + "",
ChatColor.RESET + C.cAqua + "Ultra and Hero players have",
ChatColor.RESET + C.cAqua + "instant access to our servers!",
@ -186,10 +186,12 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
int greenStartSlot = 18 + ((9 - serversToShow) / 2);
boolean showGreen = true;
long portalTime = Plugin.getMillisecondsUntilPortal(Player);
boolean beta = serverList.size() > 0 && serverList.get(0).Name.contains("BETA");
long portalTime = Plugin.getMillisecondsUntilPortal(Player, beta);
if (portalTime > 0)
{
showClock(portalTime);
showClock(portalTime, beta);
showGreen = false;
}

View File

@ -32,8 +32,8 @@ public class PartyTutorial extends Tutorial
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
manager.GetSpawn().add(84, y+69, 9),
manager.GetSpawn().add(81, y+68.5, 9),
"Creating a Party",
new String[]
{
@ -47,8 +47,8 @@ public class PartyTutorial extends Tutorial
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
manager.GetSpawn().add(84, y+69, 9),
manager.GetSpawn().add(81, y+68.5, 9),
"Inviting and Suggesting Players",
new String[]
{
@ -61,8 +61,8 @@ public class PartyTutorial extends Tutorial
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
manager.GetSpawn().add(84, y+69, 9),
manager.GetSpawn().add(81, y+68.5, 9),
"Leaving Parties",
new String[]
{
@ -73,8 +73,8 @@ public class PartyTutorial extends Tutorial
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
manager.GetSpawn().add(84, y+69, 9),
manager.GetSpawn().add(81, y+68.5, 9),
"Kicking Players from Party",
new String[]
{
@ -87,8 +87,8 @@ public class PartyTutorial extends Tutorial
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
manager.GetSpawn().add(84, y+69, 9),
manager.GetSpawn().add(81, y+68.5, 9),
"Joining Games Together",
new String[]
{
@ -103,8 +103,8 @@ public class PartyTutorial extends Tutorial
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
manager.GetSpawn().add(84, y+69, 9),
manager.GetSpawn().add(81, y+68.5, 9),
"Party Chat",
new String[]
{
@ -118,8 +118,8 @@ public class PartyTutorial extends Tutorial
));
_phases.add(new TutorialPhase(
manager.GetSpawn(),
manager.GetSpawn().add(0, y+0.5, 10),
manager.GetSpawn().add(0, -2, 0),
manager.GetSpawn().add(0, -2.1, 5),
"End",
new String[]
{

View File

@ -132,8 +132,8 @@ public class WelcomeTutorial extends Tutorial
//END
_phases.add(new TutorialPhase(
manager.GetSpawn().add(0, -3, 0),
manager.GetSpawn().add(0, -3.1, 5),
manager.GetSpawn().add(0, -2, 0),
manager.GetSpawn().add(0, -2.1, 5),
"End",
new String[]
{

View File

@ -8,5 +8,9 @@
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jedis-2.4.2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,16 @@
package mineplex.staffServer.helpdesk;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.staffServer.helpdesk.repository.ApiGetCall;
public class HelpDeskManager extends MiniPlugin
{
public HelpDeskManager(JavaPlugin plugin)
{
super("Help Desk", plugin);
new ApiGetCall("https://mineplex.jitbit.com/helpdesk/api", "Tickets&");
}
}

View File

@ -0,0 +1,29 @@
package mineplex.staffServer.helpdesk;
public class ListTicketToken
{
public int IssueID;
public int Priority;
public int StatusID;
public String IssueDate;
public String Subject;
public String Status;
public boolean UpdatedByUser;
public boolean UpdatedByPerformer;
public int CategoryID;
public String UserName;
public String Technician;
public String FirstName;
public String LastName;
public String DueDate;
public String TechFirstName;
public String TechLastName;
public String LastUpdated;
public boolean UpdatedForTechView;
public int UserID;
public int CompanyID;
public String CompanyName;
public int SectionID;
public int AssignedToUserID;
public String Category;
}

View File

@ -0,0 +1,22 @@
package mineplex.staffServer.helpdesk;
public class TicketToken
{
public int TicketID;
public int UserID;
public int AssignedToUserID;
public String IssueDate;
public String Subject;
public String Body;
public int Priority;
public int StatusID;
public int CategoryID;
public String DueDate;
public String ResolvedDate;
public String StartDate;
public int TimeSpentInSeconds;
public boolean IsCurrentUserTechInThisCategory;
public boolean IsCurrentCategoryForTechsOnly;
public boolean SubmittedByCurrentUser;
public boolean IsInKb;
}

View File

@ -0,0 +1,19 @@
package mineplex.staffServer.helpdesk.repository;
import org.apache.http.client.methods.HttpDelete;
public class ApiDeleteCall extends HelpDeskApiCallBase
{
public ApiDeleteCall(String apiUrl, int domainId, String category)
{
super(apiUrl, domainId, category);
}
public void Execute()
{
HttpDelete request = new HttpDelete(ApiUrl + DomainId + Category);
System.out.println(request.getURI().toString());
System.out.println(execute(request));
}
}

View File

@ -0,0 +1,128 @@
package mineplex.staffServer.helpdesk.repository;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
public class ApiGetCall
{
protected String ApiUrl = "https://mineplex.jitbit.com/helpdesk/api";
protected String SecretKey = "?sharedSecret={WzG49S3L6spqt4}";
private String _action;
public ApiGetCall(String apiUrl, String action)
{
ApiUrl = apiUrl;
_action = action;
}
protected String execute()
{
HttpGet request = new HttpGet(ApiUrl + SecretKey + "&" + _action);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("https", 80, PlainSocketFactory.getSocketFactory()));
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry);
connectionManager.setMaxTotal(200);
connectionManager.setDefaultMaxPerRoute(20);
HttpClient httpClient = new DefaultHttpClient(connectionManager);
InputStream in = null;
String response = "";
try
{
HttpResponse httpResponse = httpClient.execute(request);
if (httpResponse != null)
{
in = httpResponse.getEntity().getContent();
response = convertStreamToString(in);
}
}
catch (Exception ex)
{
System.out.println("HelpDeskApiCall Error:\n" + ex.getMessage());
for (StackTraceElement trace : ex.getStackTrace())
{
System.out.println(trace);
}
}
finally
{
httpClient.getConnectionManager().shutdown();
if (in != null)
{
try
{
in.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
return response;
}
protected String convertStreamToString(InputStream is)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try
{
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
is.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
return sb.toString();
}
public void Execute()
{
}
/*
public <T> T Execute(Type returnType)
{
HttpGet request = new HttpGet(ApiUrl + DomainId + Category + _action);
String response = execute(request);
System.out.println(response);
return new Gson().fromJson(response, returnType);
}
*/
}

View File

@ -0,0 +1,79 @@
package mineplex.staffServer.helpdesk.repository;
import java.lang.reflect.Type;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import com.google.gson.Gson;
public class ApiPostCall extends HelpDeskApiCallBase
{
private String _action;
public ApiPostCall(String apiUrl, int domainId, String category, String action)
{
super(apiUrl, domainId, category);
_action = action;
}
public void Execute(Object argument)
{
Gson gson = new Gson();
HttpPost request = new HttpPost(ApiUrl + DomainId + Category + _action);
System.out.println(request.getURI().toString());
try
{
StringEntity params = new StringEntity(gson.toJson(argument));
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
request.setEntity(params);
}
catch (Exception exception)
{
System.out.println("Error executing ApiPostCall(Object): \n" + exception.getMessage());
for (StackTraceElement trace : exception.getStackTrace())
{
System.out.println(trace);
}
}
System.out.println(execute(request));
}
public <T> T Execute(Class<T> returnClass)
{
return Execute(returnClass, (Object)null);
}
public <T> T Execute(Type returnType, Object argument)
{
Gson gson = new Gson();
HttpPost request = new HttpPost(ApiUrl + DomainId + Category + _action);
System.out.println(request.getURI().toString());
try
{
StringEntity params = new StringEntity(gson.toJson(argument));
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
request.setEntity(params);
}
catch (Exception exception)
{
System.out.println("Error executing ApiPostCall(Type, Object): \n" + exception.getMessage());
for (StackTraceElement trace : exception.getStackTrace())
{
System.out.println(trace);
}
}
String response = execute(request);
System.out.println(response);
return new Gson().fromJson(response, returnType);
}
}

View File

@ -0,0 +1,80 @@
package mineplex.staffServer.helpdesk.repository;
import java.lang.reflect.Type;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import com.google.gson.Gson;
public class ApiPutCall extends HelpDeskApiCallBase
{
private String _action;
public ApiPutCall(String apiUrl, int domainId, String category, String action)
{
super(apiUrl, domainId, category);
_action = action;
}
public void Execute(Object argument)
{
Gson gson = new Gson();
HttpPut request = new HttpPut(ApiUrl + DomainId + Category + _action);
System.out.println(request.getURI().toString());
try
{
StringEntity params = new StringEntity(gson.toJson(argument));
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
request.setEntity(params);
}
catch (Exception exception)
{
System.out.println("Error executing ApiPutCall(Object): \n" + exception.getMessage());
for (StackTraceElement trace : exception.getStackTrace())
{
System.out.println(trace);
}
}
System.out.println(execute(request));
}
public <T> T Execute(Class<T> returnClass)
{
return Execute(returnClass, (Object)null);
}
public <T> T Execute(Type returnType, Object argument)
{
Gson gson = new Gson();
HttpPut request = new HttpPut(ApiUrl + DomainId + Category + _action);
System.out.println(request.getURI().toString());
try
{
StringEntity params = new StringEntity(gson.toJson(argument));
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
request.setEntity(params);
}
catch (Exception exception)
{
System.out.println("Error executing ApiPutCall(Type, Object): \n" + exception.getMessage());
for (StackTraceElement trace : exception.getStackTrace())
{
System.out.println(trace);
}
}
String response = execute(request);
System.out.println(response);
return new Gson().fromJson(response, returnType);
}
}

View File

@ -0,0 +1,128 @@
package mineplex.staffServer.helpdesk.repository;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Hex;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
public abstract class HelpDeskApiCallBase
{
protected String ApiUrl = "https://mineplex.jitbit.com/helpdesk/api";
protected int DomainId = 962728;
protected String Category = "";
public HelpDeskApiCallBase(String apiUrl, int domainId, String category)
{
ApiUrl = apiUrl;
DomainId = domainId;
Category = category;
}
protected String execute(HttpRequestBase request)
{
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("https", 80, PlainSocketFactory.getSocketFactory()));
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry);
connectionManager.setMaxTotal(200);
connectionManager.setDefaultMaxPerRoute(20);
HttpClient httpClient = new DefaultHttpClient(connectionManager);
InputStream in = null;
String response = "";
try
{
HttpResponse httpResponse = httpClient.execute(request);
if (httpResponse != null)
{
in = httpResponse.getEntity().getContent();
response = convertStreamToString(in);
}
}
catch (Exception ex)
{
System.out.println("HelpDeskApiCall Error:\n" + ex.getMessage());
for (StackTraceElement trace : ex.getStackTrace())
{
System.out.println(trace);
}
}
finally
{
httpClient.getConnectionManager().shutdown();
if (in != null)
{
try
{
in.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
return response;
}
protected String getServerTime()
{
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return dateFormat.format(calendar.getTime());
}
protected String convertStreamToString(InputStream is)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try
{
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
is.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
return sb.toString();
}
}

View File

@ -0,0 +1,6 @@
package mineplex.staffServer.helpdesk.repository;
public class HelpDeskRepository
{
}

View File

@ -7,7 +7,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.*;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
@ -44,8 +43,8 @@ import mineplex.core.updater.Updater;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.game.GameServerConfig;
import net.minecraft.server.v1_7_R4.*;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -127,6 +126,8 @@ public class Arcade extends JavaPlugin
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
}

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import nautilus.game.arcade.addons.*;
@ -77,6 +78,7 @@ import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.timing.TimingManager;
@ -107,6 +109,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private GameGemManager _gameGemManager;
private GameManager _gameManager;
private GameLobbyManager _gameLobbyManager;
private GamePlayerManager _gamePlayerManager;
private GameWorldManager _gameWorldManager;
private ServerStatusManager _serverStatusManager;
private InventoryManager _inventoryManager;
@ -118,6 +121,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private SkillFactory _skillFactory;
private ClassShopManager _classShopManager;
private ClassCombatShop _classShop;
private TaskManager _taskManager;
private EloManager _eloManager;
@ -129,6 +133,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Games
private Game _game;
private HashMap<String, String> _tournamentTeam = new HashMap<String, String>();
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
@ -204,6 +210,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
_statsManager = new StatsManager(plugin);
_taskManager = new TaskManager(plugin, webAddress);
_achievementManager = new AchievementManager(_statsManager);
_inventoryManager = inventoryManager;
_cosmeticManager = cosmeticManager;
@ -222,7 +229,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_gameManager = new GameManager(this);
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
new GameFlagManager(this);
new GamePlayerManager(this);
_gamePlayerManager = new GamePlayerManager(this);
new GameAchievementManager(this);
_gameWorldManager = new GameWorldManager(this);
new MiscManager(this);
@ -345,6 +352,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _gameLobbyManager;
}
public TaskManager GetTaskManager()
{
return _taskManager;
}
public ArcadeShop GetShop()
{
@ -488,6 +500,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + event.getPlayer().getName()));
else
event.setQuitMessage(null);
_tournamentTeam.remove(event.getPlayer().getName());
}
public Game GetGame()
@ -832,4 +846,37 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
}
}
public void setTournamentTeam(Player player, GameTeam team)
{
_tournamentTeam.put(player.getName(), team.GetName());
}
public void rejoinTournamentTeam(Player player)
{
if (_game == null)
return;
if (!_tournamentTeam.containsKey(player.getName()))
return;
GameTeam curPref = _game.GetTeamPreference(player);
if (curPref != null)
return;
GameTeam curTeam = _game.GetTeam(player);
if (curTeam != null)
return;
String teamName = _tournamentTeam.get(player.getName());
for (GameTeam team : _game.GetTeamList())
{
if (team.GetName().equalsIgnoreCase(teamName))
{
_gamePlayerManager.AddTeamPreference(_game, player, team);
break;
}
}
}
}

View File

@ -459,6 +459,10 @@ public abstract class Game implements Listener
//Lobby Scoreboard
Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase());
//Save Tournament Team
if (Manager.IsTournamentServer())
Manager.setTournamentTeam(player, team);
}
public GameTeam ChooseTeam(Player player)

View File

@ -6,6 +6,7 @@ import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementLog;
import mineplex.core.achievement.AchivementData;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
@ -88,7 +89,28 @@ public class GameAchievementManager implements Listener
String nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + data.getLevel() + C.cGold + "/" + C.cYellow + type.getMaxLevel());
String progress = F.elem(C.cGreen + "+" + log.get(type).Amount);
if (log.get(type).LevelUp)
//Completed Achievement
if (data.getLevel() == type.getMaxLevel())
{
//Finishing for the first time
if (!Manager.GetTaskManager().hasCompletedTask(player, type.getName()))
{
UtilPlayer.message(player, nameLevel + " " + progress +
" " + F.elem(C.cAqua + C.Bold + "COMPLETE!"));
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
//Set Completed
Manager.GetTaskManager().completedTask(player, type.getName());
}
else
{
UtilPlayer.message(player, nameLevel + " " + progress +
" " + F.elem(C.cYellow + C.Bold + "Complete"));
}
}
//Multi-Level Achievements
else if (log.get(type).LevelUp)
{
UtilPlayer.message(player, nameLevel + " " + progress +
" " + F.elem(C.cAqua + C.Bold + "LEVEL UP!"));

View File

@ -911,14 +911,10 @@ public class GameFlagManager implements Listener
Game game = Manager.GetGame();
if (game == null) return;
if (event.getCause() != IgniteCause.SPREAD)
return;
if (game.WorldFireSpread)
return;
if (event.getBlock().getType() == Material.FIRE)
event.setCancelled(true);
event.setCancelled(true);
}
@EventHandler

View File

@ -484,6 +484,22 @@ public class GameManager implements Listener
}
}
}
@EventHandler
public void TeamTournamentAutoJoin(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Game game = Manager.GetGame();
if (game == null) return;
if (game.GetState() != GameState.Recruit)
return;
for (Player player : UtilServer.getPlayers())
Manager.rejoinTournamentTeam(player);
}
public boolean PlayerAdd(Game game, Player player, GameTeam team)
{

View File

@ -20,6 +20,8 @@ public class DamageDealtStatTracker extends StatTracker<Game>
return;
getGame().AddStat(damager, "Damage Dealt", (int) Math.round(event.GetDamage()), false, false);
getGame().AddStat(damager, getGame().GetKit(damager).GetName() + " Damage Dealt", (int) Math.round(event.GetDamage()), false, false);
if (getGame() != null && getGame().GetKit(damager) != null)
getGame().AddStat(damager, getGame().GetKit(damager).GetName() + " Damage Dealt", (int) Math.round(event.GetDamage()), false, false);
}
}

View File

@ -20,6 +20,8 @@ public class DamageTakenStatTracker extends StatTracker<Game>
return;
getGame().AddStat(damagee, "Damage Taken", (int) Math.round(event.GetDamage()), false, false);
getGame().AddStat(damagee, getGame().GetKit(damagee).GetName() + " Damage Taken", (int) Math.round(event.GetDamage()), false, false);
if (getGame() != null && getGame().GetKit(damagee) != null)
getGame().AddStat(damagee, getGame().GetKit(damagee).GetName() + " Damage Taken", (int) Math.round(event.GetDamage()), false, false);
}
}

Binary file not shown.