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

This commit is contained in:
Chiss 2014-08-23 15:04:55 +10:00
commit 0700b9df12
15 changed files with 540 additions and 25 deletions

View File

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

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

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

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

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