Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

Commit

Permalink
Several Minor Updates
Browse files Browse the repository at this point in the history
Removed 1.14.X compatibility
Added 1.15.X compatibility
  • Loading branch information
ShakeforProtein committed Dec 12, 2019
1 parent f643088 commit 3f269cf
Show file tree
Hide file tree
Showing 13 changed files with 348 additions and 47 deletions.
9 changes: 4 additions & 5 deletions TreeboTickets.iml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.15-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.15-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.0.6" level="project" />
</component>
</module>
20 changes: 18 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.ShakeforProtein</groupId>
<artifactId>TreeboTickets</artifactId>
<version>2.4.1</version>
<version>3.1.0</version>
<packaging>jar</packaging>

<name>TreeboTickets</name>
Expand Down Expand Up @@ -72,6 +72,10 @@
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -83,7 +87,19 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.15-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.0.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package me.shakeforprotein.treebotickets.Listeners.InventoryEvents;

import me.shakeforprotein.treebotickets.TreeboTickets;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;

import java.util.Set;

public class PlayerUseItem implements Listener {

private TreeboTickets pl;

public PlayerUseItem(TreeboTickets main) {
this.pl = main;
}

@EventHandler
public void playerUseItem(PlayerInteractEvent e) {
Inventory inv = Bukkit.createInventory(null,9,"AntiHack Triggered");
Player p = e.getPlayer();
if (e.getItem() != null) {
if (e.getItem().getType() == Material.WRITTEN_BOOK) {
if (e.getItem().hasItemMeta()) {
if (e.getItem().getItemMeta() instanceof BookMeta) {
net.minecraft.server.v1_15_R1.ItemStack nmsItem = getNMSItem(e.getItem());
NBTTagCompound compound = getCompound(nmsItem);
Set<String> compoundKeys = compound.getKeys();
for(String item : compoundKeys){
if(compound.get(item).asString().contains("clickEvent")){
e.getItem().setItemMeta(null);
e.getPlayer().openInventory(inv);
e.getPlayer().closeInventory();
break;
}
}
}
}
}
}
}

public net.minecraft.server.v1_15_R1.ItemStack getNMSItem(ItemStack item){
net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
return nmsItem;
}

public NBTTagCompound getCompound(net.minecraft.server.v1_15_R1.ItemStack nmsItem){
NBTTagCompound nmsCompound = (nmsItem.hasTag()) ? nmsItem.getTag() : new NBTTagCompound();
return nmsCompound;
}

public ItemStack getBukkitItem(net.minecraft.server.v1_15_R1.ItemStack nmsItem){
ItemStack bukkitItem = CraftItemStack.asBukkitCopy(nmsItem);
return bukkitItem;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package me.shakeforprotein.treebotickets.Listeners;

import me.shakeforprotein.treebotickets.TreeboTickets;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -20,17 +24,19 @@ public NotifyHub(TreeboTickets main) {
private void onPlayerJoin(PlayerJoinEvent e) {

if ((pl.getConfig().getString("isLobbyServer").equalsIgnoreCase("true")) && (!e.getPlayer().hasPlayedBefore())) {
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(pl, new Runnable() {
Bukkit.getServer().getScheduler().runTaskLater(pl, new Runnable() {
public void run() {
String command;
Player p = e.getPlayer();
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
command = "title " + p.getName() + " times 20 100 20";
Bukkit.dispatchCommand(console, command);
command = "title " + p.getName() + " subtitle [\"\",{\"text\":\"Use\",\"color\":\"green\"},{\"text\":\" \"},{\"text\":\"/hub\",\"color\":\"red\"},{\"text\":\" \"},{\"text\":\"to navigate the server\",\"color\":\"green\"}]";
Bukkit.dispatchCommand(console, command);
//command = "title " + p.getName() + " subtitle [\"\",{\"text\":\"Use\",\"color\":\"green\"},{\"text\":\" \"},{\"text\":\"/hub\",\"color\":\"red\"},{\"text\":\" \"},{\"text\":\"to navigate the server\",\"color\":\"green\"}]";
//Bukkit.dispatchCommand(console, command);
command = "title " + p.getName() + " title {\"text\":\"Welcome to TreeboMC\",\"color\":\"green\"}\n";
Bukkit.dispatchCommand(console, command);

p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder(ChatColor.GREEN + "Use " + ChatColor.RED + "/hub" + ChatColor.GREEN + " to navigate the Treebo Servers").create());
}
}, 200L);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent e) {
pl.getConfig().set("players." + p.getName() + "lastQuery", pl.baseInsert.replace("XXXVALUESPLACEHOLDERXXX", ticketData));
pl.getConfig().set("players." + p.getName() + ".ticketstate", 0);
pl.saveConfig();
createTicket.addTicketToDB(p, ticketData);
String discordString = "&type=" + type +"&user=" + p.getName() + "&contents=" + (description + " " + usersteps).replace("&", "AND");

createTicket.addTicketToDB(p, ticketData, type, description + " " + usersteps);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package me.shakeforprotein.treebotickets.Methods.CreateTicket;

import io.github.leonardosnt.bungeechannelapi.BungeeChannelApi;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import me.shakeforprotein.treebotickets.TreeboTickets;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

import javax.net.ssl.HttpsURLConnection;
import java.io.IOException;

import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class CreateTicket {

private TreeboTickets pl;


public CreateTicket(TreeboTickets main){this.pl = main;}

public void addTicketToDB(Player p, String ticketData) {
public void addTicketToDB(Player p, String ticketData, String type, String contents) {
Bukkit.getScheduler().runTaskAsynchronously(pl, new Runnable() {
@Override
public void run() {
Expand All @@ -29,6 +34,28 @@ public void run() {
while (response.next()) {
tID = response.getInt("ID");
p.sendMessage(pl.badge + "Your Ticket number is " + tID + ". Use /ticket view " + tID + " to view any updates");
try {
String discordHook = pl.getConfig().getString("discordHook");
discordHook = discordHook + "?id=" + tID + "&user=" + p.getName() + "&type=" + type + "&contents=" +contents.replace(" ", "%20");


URL url = new URL(null, discordHook, new sun.net.www.protocol.https.Handler());

HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestMethod("POST");
httpsURLConnection.setRequestProperty("User-Agent", "ShakeBrowser/5.0");
httpsURLConnection.setRequestProperty("Referer", "no-referer");
httpsURLConnection.setConnectTimeout(5000);
httpsURLConnection.connect();
System.out.println(httpsURLConnection.getResponseMessage());
if(httpsURLConnection.getErrorStream() != null){
System.out.println(discordHook);
}
}
catch(IOException e){
pl.makeLog(e);
}

while (staffResponse.next()){
String staff = staffResponse.getString("IGNAME");
pl.api.sendMessage(staff, "Player " + p.getName() + "Has just submitted ticket number " + tID);
Expand All @@ -43,5 +70,7 @@ public void run() {

}
});

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public SpecificTicketGui(TreeboTickets main) {
}

public void specificTicketGui(Player p, int t, String menuName, String fromMenu) {
Bukkit.getScheduler().runTaskAsynchronously(pl, new Runnable() {
@Override
public void run() {
Inventory individualTicketGui = Bukkit.createInventory(null, 27, menuName);
int tId = -1;
String tPlayer = "";
Expand Down Expand Up @@ -242,7 +239,5 @@ public void run() {
System.out.println(pl.err + "Encountered " + e.toString() + " during staffViewTicket()");
pl.makeLog(e);
}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.io.*;

Expand Down Expand Up @@ -46,7 +48,7 @@ public void infoHelp(String fileName, CommandSender p) {
BufferedReader in = new BufferedReader(new FileReader(infoFile));

String line = null;

if (infoList.get(fileName) != null) {
if (infoList.getString(fileName).equalsIgnoreCase("text")) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,42 @@ public void run() {
pl.getConfig().set("playerStats." + pl.getServerName(p) + "." + p.getName() + ".deaths." + column, null);
}
}
if (pl.getConfig().getConfigurationSection("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi") != null) {
if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.EzRank") != null){
statsAddQuery += " `EZRANK` = \"" + pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.EzRank") + "\",";
}
if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.EzProgress") != null){
statsAddQuery += " `EZPROGRESS` = \""+ pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.EzProgress") + "\",";
}
if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.vaultBal") != null){
statsAddQuery += " `BALANCE` = \"" + pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.vaultBal") + "\",";
}
/* if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.npcPoliceArrests") != null){
statsAddQuery += " `TOTALARRESTS` = \"" + pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.npcPoliceArrests") + "\",";
}*/
if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.bounty") != null){
statsAddQuery += " `BOUNTY` = \"" + pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.bounty") + "\",";
}
if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.totalBounty") != null){
statsAddQuery += " `ALLTIMEBOUNTY` = \"" + pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.totalBounty") + "\",";
}
if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.murders") != null){
statsAddQuery += " `MURDERS` = \"" + pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.murders") + "\",";
}
if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.timeRemaining") != null){
statsAddQuery += " `SENTENCEREMAINING` = \"" + pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.timeRemaining") + "\",";
}

if(pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.status") != null){
statsAddQuery += " `STATUS` = \"" + pl.getConfig().getString("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi.status") + "\",";
}
}


statsAddQuery += " `IGNAME` = IGNAME WHERE `UUID` ='" + p.getUniqueId() + "'";
pl.getConfig().set("playerStats." + pl.getServerName(p) + "." + p.getName() + ".deaths", null);
pl.getConfig().set("playerStats." + pl.getServerName(p) + "." + p.getName() + ".kills", null);
pl.getConfig().set("playerStats." + pl.getServerName(p) + "." + p.getName(), null);
// pl.getConfig().set("playerStats." + pl.getServerName(p) + "." + p.getName() + ".papi", null);

pl.getConfig().set("LastStatEntry", statsAddQuery);
pl.saveConfig();
Expand Down
Loading

0 comments on commit 3f269cf

Please sign in to comment.