From ebc328a9ae940c50a1ca10c6b00dcf8b81f3e94a Mon Sep 17 00:00:00 2001 From: JernejTDO Date: Mon, 2 May 2022 19:22:59 +0200 Subject: [PATCH] Upload --- .classpath | 39 +++++++ .project | 23 ++++ .settings/org.eclipse.jdt.core.prefs | 11 ++ .settings/org.eclipse.m2e.core.prefs | 4 + README.md | 100 +++++++++++++++++- pom.xml | 35 ++++++ .../net/hypple/EasyAPI/Bungee/Bungee.java | 18 ++++ src/main/java/net/hypple/EasyAPI/EasyAPI.java | 57 ++++++++++ .../net/hypple/EasyAPI/Json/JsonManager.java | 83 +++++++++++++++ src/main/java/net/hypple/EasyAPI/Main.java | 10 ++ .../net/hypple/EasyAPI/RGB/HexColors.java | 27 +++++ .../Regions/BukkitPlayerMoveEvent.java | 42 ++++++++ .../Regions/PlayerEnterRegionEvent.java | 52 +++++++++ .../Regions/PlayerExitRegionEvent.java | 52 +++++++++ .../net/hypple/EasyAPI/Regions/Region.java | 51 +++++++++ .../net/hypple/EasyAPI/Regions/Regions.java | 52 +++++++++ .../net/hypple/EasyAPI/mysql/EasyMySQL.java | 93 ++++++++++++++++ .../net/hypple/EasyAPI/Bungee/Bungee.class | Bin 0 -> 1093 bytes .../classes/net/hypple/EasyAPI/EasyAPI.class | Bin 0 -> 2849 bytes .../net/hypple/EasyAPI/Json/JsonManager.class | Bin 0 -> 3534 bytes target/classes/net/hypple/EasyAPI/Main.class | Bin 0 -> 393 bytes .../net/hypple/EasyAPI/RGB/HexColors.class | Bin 0 -> 1783 bytes .../Regions/BukkitPlayerMoveEvent.class | Bin 0 -> 2151 bytes .../Regions/PlayerEnterRegionEvent.class | Bin 0 -> 1505 bytes .../Regions/PlayerExitRegionEvent.class | Bin 0 -> 1502 bytes .../net/hypple/EasyAPI/Regions/Region.class | Bin 0 -> 2012 bytes .../net/hypple/EasyAPI/Regions/Regions.class | Bin 0 -> 2372 bytes .../net/hypple/EasyAPI/mysql/EasyMySQL.class | Bin 0 -> 3080 bytes 28 files changed, 748 insertions(+), 1 deletion(-) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 pom.xml create mode 100644 src/main/java/net/hypple/EasyAPI/Bungee/Bungee.java create mode 100644 src/main/java/net/hypple/EasyAPI/EasyAPI.java create mode 100644 src/main/java/net/hypple/EasyAPI/Json/JsonManager.java create mode 100644 src/main/java/net/hypple/EasyAPI/Main.java create mode 100644 src/main/java/net/hypple/EasyAPI/RGB/HexColors.java create mode 100644 src/main/java/net/hypple/EasyAPI/Regions/BukkitPlayerMoveEvent.java create mode 100644 src/main/java/net/hypple/EasyAPI/Regions/PlayerEnterRegionEvent.java create mode 100644 src/main/java/net/hypple/EasyAPI/Regions/PlayerExitRegionEvent.java create mode 100644 src/main/java/net/hypple/EasyAPI/Regions/Region.java create mode 100644 src/main/java/net/hypple/EasyAPI/Regions/Regions.java create mode 100644 src/main/java/net/hypple/EasyAPI/mysql/EasyMySQL.java create mode 100644 target/classes/net/hypple/EasyAPI/Bungee/Bungee.class create mode 100644 target/classes/net/hypple/EasyAPI/EasyAPI.class create mode 100644 target/classes/net/hypple/EasyAPI/Json/JsonManager.class create mode 100644 target/classes/net/hypple/EasyAPI/Main.class create mode 100644 target/classes/net/hypple/EasyAPI/RGB/HexColors.class create mode 100644 target/classes/net/hypple/EasyAPI/Regions/BukkitPlayerMoveEvent.class create mode 100644 target/classes/net/hypple/EasyAPI/Regions/PlayerEnterRegionEvent.class create mode 100644 target/classes/net/hypple/EasyAPI/Regions/PlayerExitRegionEvent.class create mode 100644 target/classes/net/hypple/EasyAPI/Regions/Region.class create mode 100644 target/classes/net/hypple/EasyAPI/Regions/Regions.class create mode 100644 target/classes/net/hypple/EasyAPI/mysql/EasyMySQL.class diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..5869b87 --- /dev/null +++ b/.classpath @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..91c2ee5 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + EasyAPI + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7251e5a --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/README.md b/README.md index cf3b39b..0346345 100644 --- a/README.md +++ b/README.md @@ -1 +1,99 @@ -# EasyAPI \ No newline at end of file +# EasyAPI +_Made for making games more easy_ +authors: + - JernejTDO + - alandioda (made regions) + +## Features + - Regions (Create regions and use their system) + - Json File manager (Save files, get body and option to create them) + - MySQL (Setup the mysql connection and use it) + - HexColer codes replacer + +## Regions +Create a region + - First you need to make to make 2 locations. + - Create the region. + - Last step add the region to the list. +```sh +Location loc1 = new Location(Bukkit.getWorld(""), 0, 0, 0); +Location loc2 = new Location(Bukkit.getWorld(""), 0, 0, 0); +Region region = new Region("", loc1, loc2); +Regions.addRegion(region); +``` + +Region Events +> PlayerEnterRegionEvent - When a player joins the region. +> PlayerExitRegionEvent - When a player leaves a region. +```sh +@EventHandler +public void regionEnter(PlayerEnterRegionEvent event) { +} + +@EventHandler +public void Region(PlayerExitRegionEvent event) { +} +``` + +Get info of region. +```sh +Region region = null; //Your region +Location loc = null; //Bukkit location + +Regions.addRegion(region); //Adds a region to the plugin. +Regions.deleteRegion(region); //Removes the region from the plugin. +Regions.getRegionInLocation(loc); //Gets the region in that location. +Regions.getRegions(); //List of all the regions created. +Regions.getRegionsByName(""); //Gets the region by name. +Regions.getRegionsInLocation(loc); //List of all the regions in that location. +``` +## Json Manager +You need to use Google`s json dependency. +```sh + + com.googlecode.json-simple + json-simple + 1.1.1 + +``` + + Json Features +```sh +import net.hypple.EasyAPI.Json.JsonManager; + +JsonManager.createJsonFile(""); +JsonManager.getJsonBody(""); +JsonManager.updateJsonBody("", JSONObject); +``` + +## MySQL +Connect to database. +_put in onEnable()_ +```sh +@Override +public void onEnable() { + EasyAPI.setupMySQL("Host", "Data Base", "Username", "Password"); +} +``` + +You need to install this dependency +```sh + + mysql + mysql-connector-java + 8.0.21 + +``` + +Get the connection to data base. +```sh +EasyAPI.mysql.GetConnection(); +``` + +## Hex Coler Codes +Its for the version 1.16+ that support RGB. You can you this on spigot and Bungee servers. +_You just need to put the & symbol in front of the hex code_ +```sh +Player player = null; //Your player +player.sendMessage(HexColors.replaceHexCodes("�f2ff message in your coler.")); +``` diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d57e4e1 --- /dev/null +++ b/pom.xml @@ -0,0 +1,35 @@ + + 4.0.0 + net.hypple + EasyAPI + 1.1.1 + EasyAPI + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + + + + org.spigotmc + spigot-api + 1.18.2-R0.1-SNAPSHOT + provided + + + + mysql + mysql-connector-java + 8.0.21 + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + \ No newline at end of file diff --git a/src/main/java/net/hypple/EasyAPI/Bungee/Bungee.java b/src/main/java/net/hypple/EasyAPI/Bungee/Bungee.java new file mode 100644 index 0000000..231272e --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/Bungee/Bungee.java @@ -0,0 +1,18 @@ +package net.hypple.EasyAPI.Bungee; + +import org.bukkit.entity.Player; + +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; + +import net.hypple.EasyAPI.EasyAPI; + +public class Bungee { + + public static void sendPlayerToServer(Player player, String server) { + ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput(); + byteArrayDataOutput.writeUTF("Connect"); + byteArrayDataOutput.writeUTF(server); + player.sendPluginMessage(EasyAPI.getInstance(), "BungeeCord", byteArrayDataOutput.toByteArray()); + } +} \ No newline at end of file diff --git a/src/main/java/net/hypple/EasyAPI/EasyAPI.java b/src/main/java/net/hypple/EasyAPI/EasyAPI.java new file mode 100644 index 0000000..ec3011a --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/EasyAPI.java @@ -0,0 +1,57 @@ +package net.hypple.EasyAPI; + +import java.awt.Color; +import java.io.File; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + +import net.hypple.EasyAPI.Json.JsonManager; +import net.hypple.EasyAPI.Regions.BukkitPlayerMoveEvent; +import net.hypple.EasyAPI.mysql.EasyMySQL; +import net.md_5.bungee.api.ChatColor; + +public class EasyAPI extends JavaPlugin { + + private static EasyAPI plugin; + public static EasyMySQL mysql; + + @Override + public void onEnable() { + + plugin = this; + + createFolder(); + defaultFile(); + + + getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); + Bukkit.getPluginManager().registerEvents(new BukkitPlayerMoveEvent(), plugin); + } + + private void createFolder() { + String dir = plugin.getServer().getWorldContainer().getAbsolutePath(); + if(dir.endsWith(".")) { + dir = dir.substring(0, dir.length() - 1); + } + File tempFile = new File(dir + "EasyAPI"); + if(!tempFile.exists()) { + new File(dir + "EasyAPI").mkdirs(); + Bukkit.getConsoleSender().sendMessage(ChatColor.of(new Color(51,255,255))+"EasyAPI §7- "+ChatColor.of(new Color(0,255,0))+"EasyAPI"+" folder was created."); + } + } + + public static EasyAPI getInstance() { + return plugin; + } + + private static void defaultFile() { + JsonManager.createJsonFile("EasyAPI"); + } + + public static void createPluginConfig(Plugin plugin) { + JsonManager.createJsonFile(plugin.getName()); + } +} + diff --git a/src/main/java/net/hypple/EasyAPI/Json/JsonManager.java b/src/main/java/net/hypple/EasyAPI/Json/JsonManager.java new file mode 100644 index 0000000..e03cdfb --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/Json/JsonManager.java @@ -0,0 +1,83 @@ +package net.hypple.EasyAPI.Json; + +import java.awt.Color; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; + +import org.bukkit.Bukkit; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import net.hypple.EasyAPI.EasyAPI; +import net.md_5.bungee.api.ChatColor; + +public class JsonManager { + + public static void createJsonFile(String name) { + String dir = EasyAPI.getInstance().getServer().getWorldContainer().getAbsolutePath(); + if(dir.endsWith(".")) { + dir = dir.substring(0, dir.length() - 1); + } + dir = dir + "EasyAPI/"; + File tempFile = new File(dir + name+".json"); + if(!tempFile.exists()) { + JSONObject jsonFile = new JSONObject(); + try { + FileWriter file = new FileWriter(dir+"/"+name+".json"); + Bukkit.getConsoleSender().sendMessage(ChatColor.of(new Color(51,255,255))+"EasyAPI §7- "+ChatColor.of(new Color(0,255,0))+name+".json"+" file was created."); + file.write(jsonFile.toJSONString()); + file.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + } + } + + public static JSONObject getJsonBody(String name) { + String dir = EasyAPI.getInstance().getServer().getWorldContainer().getAbsolutePath(); + if(dir.endsWith(".")) { + dir = dir.substring(0, dir.length() - 1); + } + dir = dir + "EasyAPI/"; + File tempFile = new File(dir + name+".json"); + if(tempFile.exists()) { + JSONParser parser = new JSONParser(); + try { + Object obj = parser.parse(new FileReader(dir+name+".json")); + JSONObject jsonObject = (JSONObject) obj; + return jsonObject; + } catch (IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + } + return null; + } + + public static void updateJsonBody(String name, JSONObject JSONObject) { + String dir = EasyAPI.getInstance().getServer().getWorldContainer().getAbsolutePath(); + if(dir.endsWith(".")) { + dir = dir.substring(0, dir.length() - 1); + } + dir = dir + "EasyAPI/"; + File tempFile = new File(dir + name+".json"); + if(tempFile.exists()) { + try { + FileWriter file = new FileWriter(dir+"/"+name+".json"); + Bukkit.getConsoleSender().sendMessage(ChatColor.of(new Color(51,255,255))+"EasyAPI §7- "+ChatColor.of(new Color(0,255,0))+name+".json"+" file was updated."); + file.write(JSONObject.toJSONString()); + file.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/hypple/EasyAPI/Main.java b/src/main/java/net/hypple/EasyAPI/Main.java new file mode 100644 index 0000000..e9d57ea --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/Main.java @@ -0,0 +1,10 @@ +package net.hypple.EasyAPI; + +public class Main { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/net/hypple/EasyAPI/RGB/HexColors.java b/src/main/java/net/hypple/EasyAPI/RGB/HexColors.java new file mode 100644 index 0000000..ea7133e --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/RGB/HexColors.java @@ -0,0 +1,27 @@ +package net.hypple.EasyAPI.RGB; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import net.md_5.bungee.api.ChatColor; + +public class HexColors { + + public static String replaceHexCodes(String str) { + Pattern unicode = Pattern.compile("\\\\u\\+[a-fA-F0-9]{4}"); + Matcher match = unicode.matcher(str); + while (match.find()) { + String code = str.substring(match.start(),match.end()); + str = str.replace(code,Character.toString((char) Integer.parseInt(code.replace("\\u+",""),16))); + match = unicode.matcher(str); + } + Pattern pattern = Pattern.compile("&#[a-fA-F0-9]{6}"); + match = pattern.matcher(str); + while (match.find()) { + String color = str.substring(match.start(),match.end()); + str = str.replace(color,ChatColor.of(color.replace("&","")) + ""); + match = pattern.matcher(str); + } + return ChatColor.translateAlternateColorCodes('&',str); + } +} diff --git a/src/main/java/net/hypple/EasyAPI/Regions/BukkitPlayerMoveEvent.java b/src/main/java/net/hypple/EasyAPI/Regions/BukkitPlayerMoveEvent.java new file mode 100644 index 0000000..105b3e6 --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/Regions/BukkitPlayerMoveEvent.java @@ -0,0 +1,42 @@ +package net.hypple.EasyAPI.Regions; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +public class BukkitPlayerMoveEvent implements Listener { + + @EventHandler + public void move(PlayerMoveEvent event) { + if(event.getFrom().getBlockX() != event.getTo().getBlockX() + || event.getFrom().getBlockY() != event.getTo().getBlockY() + || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) { + + Region to = Regions.getRegionInLocation(event.getTo()); + Region from = Regions.getRegionInLocation(event.getFrom()); + + if(to != null) { + if(from != null) { + if(to != from) { + PlayerEnterRegionEvent enterEvent = new PlayerEnterRegionEvent(event.getPlayer(), from, to, event.isCancelled()); + Bukkit.getPluginManager().callEvent(enterEvent); + PlayerExitRegionEvent exitEvent = new PlayerExitRegionEvent(event.getPlayer(), from, to, enterEvent.isCanceled()); + Bukkit.getPluginManager().callEvent(exitEvent); + event.setCancelled(exitEvent.isCanceled()); + } + } else { + PlayerEnterRegionEvent enterEvent = new PlayerEnterRegionEvent(event.getPlayer(), from, to, event.isCancelled()); + Bukkit.getPluginManager().callEvent(enterEvent); + event.setCancelled(enterEvent.isCanceled()); + } + } else { + if(from != null) { + PlayerExitRegionEvent exitEvent = new PlayerExitRegionEvent(event.getPlayer(), from, to, event.isCancelled()); + Bukkit.getPluginManager().callEvent(exitEvent); + event.setCancelled(exitEvent.isCanceled()); + } + } + } + } +} diff --git a/src/main/java/net/hypple/EasyAPI/Regions/PlayerEnterRegionEvent.java b/src/main/java/net/hypple/EasyAPI/Regions/PlayerEnterRegionEvent.java new file mode 100644 index 0000000..c1980f6 --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/Regions/PlayerEnterRegionEvent.java @@ -0,0 +1,52 @@ +package net.hypple.EasyAPI.Regions; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerEnterRegionEvent extends Event { + + private static final HandlerList handlers = new HandlerList(); + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + private Region from; + private Region to; + private Player player; + private boolean isCanceled; + + public PlayerEnterRegionEvent(Player player, Region from, Region to, boolean isCanceled) { + this.from = from; + this.to = to; + this.player = player; + this.isCanceled = isCanceled; + } + + public Region getFrom() { + return from; + } + + public Region getTo() { + return to; + } + + public Player getPlayer() { + return player; + } + + public boolean isCanceled() { + return isCanceled; + } + + public void setCanceled(boolean isCanceled) { + this.isCanceled = isCanceled; + } + + +} diff --git a/src/main/java/net/hypple/EasyAPI/Regions/PlayerExitRegionEvent.java b/src/main/java/net/hypple/EasyAPI/Regions/PlayerExitRegionEvent.java new file mode 100644 index 0000000..de2728c --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/Regions/PlayerExitRegionEvent.java @@ -0,0 +1,52 @@ +package net.hypple.EasyAPI.Regions; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerExitRegionEvent extends Event { + + private static final HandlerList handlers = new HandlerList(); + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + private Region from; + private Region to; + private Player player; + private boolean isCanceled; + + public PlayerExitRegionEvent(Player player, Region from, Region to, boolean isCanceled) { + this.from = from; + this.to = to; + this.player = player; + this.isCanceled = isCanceled; + } + + public Region getFrom() { + return from; + } + + public Region getTo() { + return to; + } + + public Player getPlayer() { + return player; + } + + public boolean isCanceled() { + return isCanceled; + } + + public void setCanceled(boolean isCanceled) { + this.isCanceled = isCanceled; + } + + +} diff --git a/src/main/java/net/hypple/EasyAPI/Regions/Region.java b/src/main/java/net/hypple/EasyAPI/Regions/Region.java new file mode 100644 index 0000000..ba92797 --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/Regions/Region.java @@ -0,0 +1,51 @@ +package net.hypple.EasyAPI.Regions; + +import org.bukkit.Location; + +public class Region { + + private String name; + private Location location_0; + private Location location_1; + + public Region(String regionName, Location location_0, Location location_1) { + this.name = regionName; + sortLocations(location_0, location_1); + } + + private void sortLocations(Location loc1, Location loc2) { + location_0 = new Location(loc1.getWorld(), Math.min(loc1.getX(), loc2.getX()), Math.min(loc1.getY(), loc2.getY()), Math.min(loc1.getZ(), loc2.getZ())); + location_1 = new Location(loc1.getWorld(), Math.max(loc1.getX(), loc2.getX()), Math.max(loc1.getY(), loc2.getY()), Math.max(loc1.getZ(), loc2.getZ())); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Location getLocation_0() { + return location_0; + } + + public void setLocation_0(Location location_0) { + sortLocations(location_0, location_1); + } + + public Location getLocation_1() { + return location_1; + } + + public void setLocation_1(Location location_1) { + sortLocations(location_0, location_1); + } + + public boolean isInRegion(Location location) { + boolean isInX = location.getX() >= location_0.getX() && location.getX() <= location_1.getX(); + boolean isInY = location.getY() >= location_0.getY() && location.getY() <= location_1.getY(); + boolean isInZ = location.getZ() >= location_0.getZ() && location.getZ() <= location_1.getZ(); + return isInX && isInY && isInZ; + } +} \ No newline at end of file diff --git a/src/main/java/net/hypple/EasyAPI/Regions/Regions.java b/src/main/java/net/hypple/EasyAPI/Regions/Regions.java new file mode 100644 index 0000000..3151788 --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/Regions/Regions.java @@ -0,0 +1,52 @@ +package net.hypple.EasyAPI.Regions; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; + +public class Regions { + + private static List regionsList = new ArrayList<>(); + + public static void addRegion(Region region) { + regionsList.add(region); + } + + public static void deleteRegion(Region region) { + regionsList.remove(region); + } + + public static List getRegionsByName(String name) { + List reg = new ArrayList<>(); + for(Region region : regionsList) { + if(region.getName().equals(name)) { + reg.add(region); + } + } + return reg; + } + + public static List getRegions() { + return regionsList; + } + + public static List getRegionsInLocation(Location loc) { + List reg = new ArrayList<>(); + for(Region region : regionsList) { + if(region.isInRegion(loc)) { + reg.add(region); + } + } + return reg; + } + + public static Region getRegionInLocation(Location loc) { + for(Region region : regionsList) { + if(region.isInRegion(loc)) { + return region; + } + } + return null; + } +} diff --git a/src/main/java/net/hypple/EasyAPI/mysql/EasyMySQL.java b/src/main/java/net/hypple/EasyAPI/mysql/EasyMySQL.java new file mode 100644 index 0000000..cbc0928 --- /dev/null +++ b/src/main/java/net/hypple/EasyAPI/mysql/EasyMySQL.java @@ -0,0 +1,93 @@ +package net.hypple.EasyAPI.mysql; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class EasyMySQL { + + public Connection connection; + + String host; + String database; + String username; + String password; + + public EasyMySQL(String host, String database, String username, String password) { + this.host = host; + this.database = database; + this.username = username; + this.password = password; + } + + public boolean CanConnect() { + if(GetConnection() != null) { + return true; + } + return false; + } + + public static String mysql_real_escape_string(String str) { + if (str == null) { + return ""; + } + + if (str.replaceAll("[a-zA-Z0-9_!@#$%^&*()-=+~.;:,\\Q[\\E\\Q]\\E<>{}\\/? ]","").length() < 1) { + return str; + } + + String clean_string = str; + clean_string = clean_string.replaceAll("\\\\", "\\\\\\\\"); + clean_string = clean_string.replaceAll("\\n","\\\\n"); + clean_string = clean_string.replaceAll("\\r", "\\\\r"); + clean_string = clean_string.replaceAll("\\t", "\\\\t"); + clean_string = clean_string.replaceAll("\\00", "\\\\0"); + clean_string = clean_string.replaceAll("'", "\\\\'"); + clean_string = clean_string.replaceAll("\\\"", "\\\\\""); + return clean_string; + } + + public static String mysql_real_date_string(Date date) { + SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.format(date); + } + + public Connection GetConnection() { + if (connection != null) { + try { + if(connection.isClosed() || !connection.isValid(28800)) { + //Class.forName("com.mysql.jdbc.Driver"); + connection = DriverManager.getConnection("jdbc:mysql://" + host + ":3306/" + database + "?useSSL=false&serverTimezone=UTC&tcpKeepAlive=true&autoReconnect=true", username, password); + } + return connection; + } catch (SQLException e) { + e.printStackTrace(); + } + } + try{ + //Class.forName("com.mysql.jdbc.Driver"); + connection = DriverManager.getConnection("jdbc:mysql://" + host + ":3306/" + database + "?useSSL=false&serverTimezone=UTC&tcpKeepAlive=true&autoReconnect=true", username, password); + return connection; + } catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public void Update(Connection connection, String command) { + if (command == null) { + return; + } + try { + Statement st = connection.createStatement(); + st.executeUpdate(command); + st.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/target/classes/net/hypple/EasyAPI/Bungee/Bungee.class b/target/classes/net/hypple/EasyAPI/Bungee/Bungee.class new file mode 100644 index 0000000000000000000000000000000000000000..e737479a10c09b4532293b6447c1cb1b2e345007 GIT binary patch literal 1093 zcma)5T~8B16g^XxF0_l3RuECKAn3MKMif7i8WW0=kQ5;)^1{=!OqPXqrrDi^^k?}b z^}!$Dk22nEYZ_x4d6_$R=FXXW?z#8pukSwqY~!7c1Vdg)!_PbIc2n|CBJAuO?ej{c zJShjphQ*M%5LbdXh4T1e{X#YjL-M_^eDi@}!Y!OISiAa6rZ9nN2a`xL%vOCRKS!;) z430&;DH*a=-4M+a5%{q`IJC^UA2O^~|CdLZ079wGj+&xFkh&&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gGmGTVAH!wZ4QHDYH+2jl!-UL2fdB~X ztadfc<#}*~(XvG6A$1I^g2X&GkXLoPs4kX{D;TA5d7T6ycZe2YJc7Iq$KS}0X02jL zbxJ|URVWs)tRw~ND*G6aB1Ze{mdLpIyy;|(P^vR{4TSxGmS`xGxIV(>HIIU}%Q5ER zn!@Hf<6&XCRD(W;7c@N2)>plh&tBfo>8_@TVHPZdjn7D^s^dkxBoJ{~iQOSQ_w2F` z_f_^IdPSl9>Kt$vt>ZMfF}yCYBrI0b-#;DP*%ZT@Ke^?>bL!BLS>B%D~=E;0PH72nQ_NN<_QTBOeX0+QZ zgy&3xRqS#~p6O&LzJUc?U|NNl5uwlUg@(@snir5dRdO9eUBVHm<4YCx(jalQ5yX@X z7J?Z@ZVX#F7IxOKDg^IJCak_ zAH|HDM&IOW)bPBIp^*`-=Lx?79h}`Wu8q)jM13yMA>$TnnT^Wt7aH|Fk}(w=PPZqI zSMbD5ENhRpSI}LPt>8@h4vq}o!TG`VNeoQj>Exvfo~N+i;lQ5hu`sEL!n1+I;|;f+Rx#mf<$u!~2BbFbCQP_>k55h#)LQoIC&R0 zG|szve2h;5plDfD2&f@Yzw%yP-wxkLgsXA&!4+z>g&K9qOOyC?rdV<6f`@u7_TJO0 p$5;3|)H}qx@)d8J!cD=t&(l4?$PW6t0jCr-Z&O3ydtM{>;eX{K+Ry+1 literal 0 HcmV?d00001 diff --git a/target/classes/net/hypple/EasyAPI/Json/JsonManager.class b/target/classes/net/hypple/EasyAPI/Json/JsonManager.class new file mode 100644 index 0000000000000000000000000000000000000000..81e81b631d85aa5abb81016f7e66cd8f69c252dc GIT binary patch literal 3534 zcmcImNpKWZ82(;n#-0of2_qmukwj1uvJ9YrCW4a4G9j5DK`M~3{ksI#UvzxX4v@Q_svXWYQ zi*U1{@U|YkM2&Ut51yO-H zlf?D6s$vFa3QQT)ow#W`nwez0tLqykOU0kkCIergVm4|7Dmk%N&+gH)GL42VD?1qL z&+XoAI5DreZ3?c$Tm@G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FD;nO%DuY(%UJEly zf{>!>=HeX;q2`e?z1F_h86uuTa2^T-Th2TjF!37`4M~C;bI6%Hxu%BwKJXHgX)Ky!C_n z&|8GmO8tO-RMpwFMJ}}>@{rk`nKN_d%=*vYpT7a@VK;#YL(S%%e%ZUZvAAA0I=xpX zZ}hkP!gTD8eqtFt?$&LOyS}S_%WW@#C_~j>dN$VF1)&oF-%_?cH81^hhe4h zU(#zo*f2ZZONQtN*STgWH70QI8&h(`a~R?`k`jYDQrq@SuNTmz)RfsdH0&0)c$K=I$h2!goW%X9nGb%na@F zNWT%SCUppue?ZE4WR!C$h@QJ$6k-!m%?$-Ew$JnS$mgViY5*YIi7V z)jn3Wtv*WHW*_TXF51V&fVC=RSVWX6C5dr{`py%JCE_6_+4Cy}yr`zwzGS3I>4YGv zlt~DyiWfn(7%I>LHab}`drbR*)$!qrvWY)@ENH?==P+<-9K03^u3{^s^ZGcr912z- zRwYCnroHi*9K&0#hJtnM1mFY87Rto6!id@_>D?hsYqCP#&$?GPF7*?7)nvyP{{Yo= B7#siq literal 0 HcmV?d00001 diff --git a/target/classes/net/hypple/EasyAPI/Regions/PlayerExitRegionEvent.class b/target/classes/net/hypple/EasyAPI/Regions/PlayerExitRegionEvent.class new file mode 100644 index 0000000000000000000000000000000000000000..4e71fe4e9c38aa4564c88e28f985abf575e568f2 GIT binary patch literal 1502 zcma)5+fLg+5Iq}mA&E=4reG*dN>UtiF;L!$kSY|^N>PPc6sf$KWSh7c8#x9wZ~dS? z^cEqtQa_*{Rdsf4kxQ+JJY;rf=FFTqv;On<=WhV}c$PwpVaMUV(e7Sd+1#j_o$ia1 zSH>IOvRtQQoY-cUd)1GYA9$)a-0@S0Gvr;bWt?AMTv)!rh1ZZVhRL?+G;Qv67*=cl zCA|!SHLK%4XNbS|+)IYF+87E!V@i(sE<^H4GGb7NYCFE=cSE+6nz1@ZrqkdyZ!)km zB6ZNPEywZ?878z!ojM=6O`gIm!^$|08O&f_!2)vB`ao7lgW;iq1dU@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