From 13b90e1142db3bf67c955ac3052ae0fb175aab77 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 22 Aug 2014 13:32:22 -0500 Subject: [PATCH 01/11] Preliminary work on help desk integration with Customer Support server. Updated DisguiseSheep with values from craftbukkit.jar --- .../disguise/disguises/DisguiseSheep.java | 10 +- Plugins/Mineplex.StaffServer/.classpath | 4 + .../staffServer/helpdesk/HelpDeskManager.java | 16 +++ .../staffServer/helpdesk/ListTicketToken.java | 29 ++++ .../staffServer/helpdesk/TicketToken.java | 22 +++ .../helpdesk/repository/ApiDeleteCall.java | 19 +++ .../helpdesk/repository/ApiGetCall.java | 128 ++++++++++++++++++ .../helpdesk/repository/ApiPostCall.java | 79 +++++++++++ .../helpdesk/repository/ApiPutCall.java | 80 +++++++++++ .../repository/HelpDeskApiCallBase.java | 128 ++++++++++++++++++ .../repository/HelpDeskRepository.java | 6 + 11 files changed, 516 insertions(+), 5 deletions(-) create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/HelpDeskManager.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/ListTicketToken.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/TicketToken.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiDeleteCall.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiGetCall.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiPostCall.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiPutCall.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/HelpDeskApiCallBase.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/HelpDeskRepository.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java index c6d4cdb7d..21d6fffaa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java @@ -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))); } } diff --git a/Plugins/Mineplex.StaffServer/.classpath b/Plugins/Mineplex.StaffServer/.classpath index 0169f5fdb..69044860b 100644 --- a/Plugins/Mineplex.StaffServer/.classpath +++ b/Plugins/Mineplex.StaffServer/.classpath @@ -8,5 +8,9 @@ + + + + diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/HelpDeskManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/HelpDeskManager.java new file mode 100644 index 000000000..860193f09 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/HelpDeskManager.java @@ -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"); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/ListTicketToken.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/ListTicketToken.java new file mode 100644 index 000000000..f5a18d85d --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/ListTicketToken.java @@ -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; +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/TicketToken.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/TicketToken.java new file mode 100644 index 000000000..fdbe36826 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/TicketToken.java @@ -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; +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiDeleteCall.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiDeleteCall.java new file mode 100644 index 000000000..3782e6222 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiDeleteCall.java @@ -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)); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiGetCall.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiGetCall.java new file mode 100644 index 000000000..7758f67ef --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiGetCall.java @@ -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 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); + } + */ +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiPostCall.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiPostCall.java new file mode 100644 index 000000000..34443db38 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiPostCall.java @@ -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 Execute(Class returnClass) + { + return Execute(returnClass, (Object)null); + } + + public 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); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiPutCall.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiPutCall.java new file mode 100644 index 000000000..e56c45bec --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/ApiPutCall.java @@ -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 Execute(Class returnClass) + { + return Execute(returnClass, (Object)null); + } + + public 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); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/HelpDeskApiCallBase.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/HelpDeskApiCallBase.java new file mode 100644 index 000000000..37d6b02c8 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/HelpDeskApiCallBase.java @@ -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(); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/HelpDeskRepository.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/HelpDeskRepository.java new file mode 100644 index 000000000..1b7453523 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/repository/HelpDeskRepository.java @@ -0,0 +1,6 @@ +package mineplex.staffServer.helpdesk.repository; + +public class HelpDeskRepository +{ + +} From 9fad775f73ae73a7f2658d710247c1bc37ae432e Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 23 Aug 2014 07:50:07 +1000 Subject: [PATCH 02/11] More cosmetics --- .../mineplex/core/gadget/GadgetManager.java | 17 ++- .../core/gadget/gadgets/ItemDuelingSword.java | 66 +++++++++ .../core/gadget/gadgets/ItemFootball.java | 125 ++++++++++++++++ .../core/gadget/gadgets/MorphCow.java | 66 +++++++++ .../core/gadget/gadgets/MorphNotch.java | 63 ++++++++ .../core/gadget/gadgets/MorphVillager.java | 2 +- .../src/mineplex/core/mount/MountManager.java | 14 ++ .../src/mineplex/hub/HubManager.java | 140 +++++++++--------- 8 files changed, 424 insertions(+), 69 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemDuelingSword.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFootball.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCow.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphNotch.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index b89da031b..4d853146b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -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) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemDuelingSword.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemDuelingSword.java new file mode 100644 index 000000000..7d56300dd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemDuelingSword.java @@ -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); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFootball.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFootball.java new file mode 100644 index 000000000..3ffa7f9af --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFootball.java @@ -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 _active = new HashSet(); + + 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); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCow.java new file mode 100644 index 000000000..b8098c104 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCow.java @@ -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); + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphNotch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphNotch.java new file mode 100644 index 000000000..742a71d73 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphNotch.java @@ -0,0 +1,63 @@ +package mineplex.core.gadget.gadgets; + +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.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 +{ + 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); + } + + @Override + public void EnableCustom(final Player player) + { + this.ApplyArmor(player); + + DisguisePlayer disguise = new DisguisePlayer(player); + disguise.setName("Notch"); + 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."); + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphVillager.java index 19b57e254..30a665a6a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphVillager.java @@ -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); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 80e90982a..d9ea2cea1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -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); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index d29e82c32..31d726d64 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -19,7 +19,9 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; 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; @@ -410,12 +412,6 @@ public class HubManager extends MiniClientPlugin } } - @EventHandler - public void PlayerRespawn(PlayerRespawnEvent event) - { - event.setRespawnLocation(GetSpawn()); - } - @EventHandler(priority = EventPriority.MONITOR) public void OnChunkLoad(ChunkLoadEvent event) { @@ -475,79 +471,88 @@ public class HubManager extends MiniClientPlugin else event.getPlayer().setOp(false); } + + @EventHandler + public void PlayerRespawn(PlayerRespawnEvent event) + { + event.setRespawnLocation(GetSpawn()); + } @EventHandler(priority = EventPriority.LOW) public void PlayerJoin(PlayerJoinEvent event) { - try + Player player = event.getPlayer(); + + //Public Message + event.setJoinMessage(null); + + //Teleport + player.teleport(GetSpawn()); + + //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 +663,14 @@ public class HubManager extends MiniClientPlugin @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 +944,6 @@ public class HubManager extends MiniClientPlugin { } + + } From e5944ff87223b2c0f01b64785cc1eb475931d377 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 23 Aug 2014 08:40:02 +1000 Subject: [PATCH 03/11] Spawn location fix --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 31d726d64..e63c5c903 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -144,7 +144,7 @@ public class HubManager extends MiniClientPlugin _portal = portal; - _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 82, 0.5); _textCreator = new TextManager(this); _parkour = new ParkourManager(this, donationManager, taskManager); From e40cb17e476ef71eabe74365393ff974a62ad3b1 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 23 Aug 2014 08:52:50 +1000 Subject: [PATCH 04/11] Updated tutorial locations --- .../src/mineplex/hub/HubManager.java | 6 ++-- .../mineplex/hub/modules/WorldManager.java | 8 +++--- .../hub/tutorial/types/PartyTutorial.java | 28 +++++++++---------- .../hub/tutorial/types/WelcomeTutorial.java | 4 +-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index e63c5c903..578e0dd48 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -144,7 +144,7 @@ public class HubManager extends MiniClientPlugin _portal = portal; - _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 82, 0.5); + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); _textCreator = new TextManager(this); _parkour = new ParkourManager(this, donationManager, taskManager); @@ -475,7 +475,7 @@ public class HubManager extends MiniClientPlugin @EventHandler public void PlayerRespawn(PlayerRespawnEvent event) { - event.setRespawnLocation(GetSpawn()); + event.setRespawnLocation(GetSpawn().add(0, 10, 0)); } @EventHandler(priority = EventPriority.LOW) @@ -487,7 +487,7 @@ public class HubManager extends MiniClientPlugin event.setJoinMessage(null); //Teleport - player.teleport(GetSpawn()); + player.teleport(GetSpawn().add(0, 10, 0)); //Survival player.setGameMode(GameMode.SURVIVAL); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index 8f7999986..9d95e1128 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -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")) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java index 585b414df..e8c7d1a8c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/PartyTutorial.java @@ -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[] { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java index f18e136d1..5eb6b5ebb 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/types/WelcomeTutorial.java @@ -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[] { From ebb4c44bdc1ea93f51715d9e10a9502b910ae782 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 22 Aug 2014 18:21:23 -0500 Subject: [PATCH 05/11] Tweaked player disguise. --- .../mineplex/core/disguise/disguises/DisguisePlayer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index e1a0b4079..eeb9b79e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -2,6 +2,7 @@ package mineplex.core.disguise.disguises; import java.util.UUID; +import mineplex.core.common.util.UUIDFetcher; import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn; @@ -10,6 +11,7 @@ import net.minecraft.util.com.mojang.authlib.GameProfile; public class DisguisePlayer extends DisguiseHuman { private String _name; + private UUID _uuid; public DisguisePlayer(org.bukkit.entity.Entity entity) { @@ -29,6 +31,8 @@ public class DisguisePlayer extends DisguiseHuman _name = name.substring(0, 16); else _name = name; + + _uuid = UUIDFetcher.getUUIDOf(_name); } @Override @@ -36,7 +40,7 @@ public class DisguisePlayer extends DisguiseHuman { PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); packet.a = Entity.getId(); - packet.b = new GameProfile(UUID.randomUUID(), _name); + packet.b = new GameProfile(_uuid, _name); packet.c = MathHelper.floor(Entity.locX * 32.0D); packet.d = MathHelper.floor(Entity.locY * 32.0D); packet.e = MathHelper.floor(Entity.locZ * 32.0D); From 3a47a161c5b519103f3eaee540fd00e17762d0f9 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 22 Aug 2014 22:53:15 -0500 Subject: [PATCH 06/11] Enabled snake parkour Updated servermanager/serverNpcPage to handle free and beta timers. --- .../mineplex/hub/modules/ParkourManager.java | 3 +-- .../mineplex/hub/server/ServerManager.java | 19 +++++++++---------- .../mineplex/hub/server/ui/ServerNpcPage.java | 16 +++++++++------- .../staffServer/helpdesk/HelpDeskManager.java | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index 12e8b0d39..0fe0c7daf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -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); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 70e090b22..9db284f4b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -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 _serverPortalLocations = new NautHashMap(); // Join Time for Free Players Timer - private NautHashMap _freeJoinTime = new NautHashMap(); + private NautHashMap _joinTime = new NautHashMap(); 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) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index af09e5de9..832e84af7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -78,18 +78,18 @@ public class ServerNpcPage extends ShopPageBase 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 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; } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/HelpDeskManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/HelpDeskManager.java index 860193f09..d07f71e74 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/HelpDeskManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/helpdesk/HelpDeskManager.java @@ -11,6 +11,6 @@ public class HelpDeskManager extends MiniPlugin { super("Help Desk", plugin); - new ApiGetCall("https://mineplex.jitbit.com/helpdesk/api", "Tickets"); + new ApiGetCall("https://mineplex.jitbit.com/helpdesk/api", "Tickets&"); } } From 3ec43f90e83a1d0e8bb1d771a76fa5c4601ca75d Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 23 Aug 2014 15:04:43 +1000 Subject: [PATCH 07/11] GameAchievementManager now utilises TaskManager to record whether or not people have previously completed Achievements --- .../core/achievement/AchivementData.java | 2 + .../core/gadget/gadgets/MorphBlock.java | 2 +- .../core/gadget/gadgets/MorphPumpkinKing.java | 3 ++ .../core/gadget/gadgets/MorphSnowman.java | 46 ------------------- .../nautilus/game/arcade/ArcadeManager.java | 8 ++++ .../managers/GameAchievementManager.java | 24 +++++++++- 6 files changed, 37 insertions(+), 48 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSnowman.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchivementData.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchivementData.java index a373d0537..695f7635e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchivementData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchivementData.java @@ -1,5 +1,7 @@ package mineplex.core.achievement; +import org.bukkit.ChatColor; + public class AchivementData { private int _level; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java index 37cd056e2..060a523bf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java @@ -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); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java index 93acca25d..4cd918105 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java @@ -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() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSnowman.java deleted file mode 100644 index 13633a88b..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSnowman.java +++ /dev/null @@ -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); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 497a8c505..4b68c2975 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -77,6 +77,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; @@ -118,6 +119,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private SkillFactory _skillFactory; private ClassShopManager _classShopManager; private ClassCombatShop _classShop; + private TaskManager _taskManager; private EloManager _eloManager; @@ -204,6 +206,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; @@ -345,6 +348,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return _gameLobbyManager; } + + public TaskManager GetTaskManager() + { + return _taskManager; + } public ArcadeShop GetShop() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameAchievementManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameAchievementManager.java index d5dfd24e7..d172d2bf9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameAchievementManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameAchievementManager.java @@ -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!")); From 931cb5ece8f8df711755e05d9102ab8fb28a6296 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 23 Aug 2014 00:40:07 -0500 Subject: [PATCH 08/11] Removed MineKart code. Fixed up DisguisePlayer Added ProfileLoader Fixed up Notch gadget. --- .../core/common/util/ProfileLoader.java | 118 ++++++++++++++++++ .../disguise/disguises/DisguisePlayer.java | 21 +--- .../mineplex/core/gadget/GadgetManager.java | 2 +- .../core/gadget/gadgets/MorphNotch.java | 13 +- .../src/mineplex/hub/HubManager.java | 9 +- Website/LOCWebsite.suo | Bin 474624 -> 474624 bytes 6 files changed, 136 insertions(+), 27 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ProfileLoader.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ProfileLoader.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ProfileLoader.java new file mode 100644 index 000000000..5c105a203 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ProfileLoader.java @@ -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()); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index eeb9b79e3..f17553e2b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -1,8 +1,5 @@ package mineplex.core.disguise.disguises; -import java.util.UUID; - -import mineplex.core.common.util.UUIDFetcher; import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn; @@ -10,29 +7,23 @@ import net.minecraft.util.com.mojang.authlib.GameProfile; public class DisguisePlayer extends DisguiseHuman { - private String _name; - private UUID _uuid; + 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; - - _uuid = UUIDFetcher.getUUIDOf(_name); + _profile = profile; } @Override @@ -40,7 +31,7 @@ public class DisguisePlayer extends DisguiseHuman { PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); packet.a = Entity.getId(); - packet.b = new GameProfile(_uuid, _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); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 4d853146b..6f269b8fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -101,7 +101,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphBlock(this)); addGadget(new MorphVillager(this)); addGadget(new MorphCow(this)); - //addGadget(new MorphNotch(this)); + addGadget(new MorphNotch(this)); // Particles addGadget(new ParticleGreen(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphNotch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphNotch.java index 742a71d73..da639457f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphNotch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphNotch.java @@ -1,11 +1,15 @@ 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; @@ -14,7 +18,9 @@ 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[] @@ -24,6 +30,8 @@ public class MorphNotch extends MorphGadget }, 50000, ArmorSlot.Helmet, Material.SKULL_ITEM, (byte)3); + + _notchProfile = new ProfileLoader(UUIDFetcher.getUUIDOf("Notch").toString(), "Notch").loadProfile(); } @Override @@ -31,8 +39,7 @@ public class MorphNotch extends MorphGadget { this.ApplyArmor(player); - DisguisePlayer disguise = new DisguisePlayer(player); - disguise.setName("Notch"); + DisguisePlayer disguise = new DisguisePlayer(player, _notchProfile); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 578e0dd48..d76db3952 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -19,7 +19,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; @@ -57,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; @@ -421,11 +418,7 @@ public class HubManager extends MiniClientPlugin { 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); diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index aff2fcd81f56192e714692b9c44a0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``_cAzuHBmVmQ&i6vC>&p0QZ#Ev1#%e#DH z1?_z~Rh``>azOT9qPlvfULR;BCltp}nR98Tz6xZGFVi$9!`EU)_ijPAwLhe9WBlHG z=2hS)Ux-QQKSBJn>7wouW^I~^4-T49a!MS=fAsJL7=Bqq;?iF6#i)vQk($I^W5-vu zouZf7W+aV|z4>yE`&928Q#!sn{vl4826n8voyu_I9bqth;aic6wr}(}ytR{f)ZEQt zR>o6FO8!4_&`e@{J9%jIOAZ~NwgXpRCc{l^mFu*40nFe~gMScxn(d$OKK05lKl{tm zGn!xg`1wOIa`STg$eZU-m$+x-=K%30L48!twcjqicKe8gUbAAwhoa+$0dvC5qa;nJ zE}CFLM?VfeS(pTqQg`Ux?Ib zlaWoPE*YWJQ5TwknP188G5#&S312DEtMJa>vv?J0iHxI-@7BYCD?-Qkhx8mQvJ!=P zm+R4ZYPvpIg^Kh74c{-+(=a?mcOLpqG+0nml#u;QcTPrUf$kZ3ZKY=Ed-!6);l?{A zOCNc-U~RTOCmI&f#FDW|HJGhiE$A)K{k~(|3;WEFeZu_F!iLVJlxCMrwW;=L`huuK z^Yx) Date: Sat, 23 Aug 2014 01:49:48 -0500 Subject: [PATCH 09/11] Enabled debugging in Hub/Arcade --- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 4 ++++ .../src/nautilus/game/arcade/Arcade.java | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 2f3069d40..abae814d9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -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 diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 553c90c1f..b4dbfd5c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -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); } From af9bf0727ae15997c2ef9e18406f900b6af6e88a Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 23 Aug 2014 17:55:28 +1000 Subject: [PATCH 10/11] Fixed damage taken stat NPE Added tournament team auto-rejoin --- .../mineplex/core/mount/types/MountSheep.java | 33 +++++++++++---- .../nautilus/game/arcade/ArcadeManager.java | 41 ++++++++++++++++++- .../src/nautilus/game/arcade/game/Game.java | 4 ++ .../game/arcade/managers/GameFlagManager.java | 6 +-- .../game/arcade/managers/GameManager.java | 16 ++++++++ .../arcade/stats/DamageTakenStatTracker.java | 4 +- 6 files changed, 89 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java index 540d31007..cf6b83596 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java @@ -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); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 4b68c2975..64ce80608 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -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.*; @@ -108,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; @@ -131,6 +133,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Games private Game _game; + + private HashMap _tournamentTeam = new HashMap(); public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, @@ -225,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); @@ -496,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() @@ -840,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; + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 65f7c74de..8a71d61f6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -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) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 4e1499814..be864a7a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -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 diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 8f20258ac..874a50fce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -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) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageTakenStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageTakenStatTracker.java index bd3b99609..581f60b42 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageTakenStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageTakenStatTracker.java @@ -20,6 +20,8 @@ public class DamageTakenStatTracker extends StatTracker 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); } } From 7348a2695163a2614b63f7eb6bd77329c3153228 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 23 Aug 2014 18:00:23 +1000 Subject: [PATCH 11/11] fixed damage dealt npe --- .../nautilus/game/arcade/stats/DamageDealtStatTracker.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageDealtStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageDealtStatTracker.java index 4e110af91..9f1b03693 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageDealtStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageDealtStatTracker.java @@ -20,6 +20,8 @@ public class DamageDealtStatTracker extends StatTracker 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); } }