Upload
This commit is contained in:
39
.classpath
Normal file
39
.classpath
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
23
.project
Normal file
23
.project
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>EasyAPI</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11
.settings/org.eclipse.jdt.core.prefs
Normal file
11
.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -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
|
||||
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
98
README.md
98
README.md
@@ -1 +1,99 @@
|
||||
# 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("<World Name>"), 0, 0, 0);
|
||||
Location loc2 = new Location(Bukkit.getWorld("<World Name>"), 0, 0, 0);
|
||||
Region region = new Region("<Region Name>", 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("<Name>"); //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
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
Json Features
|
||||
```sh
|
||||
import net.hypple.EasyAPI.Json.JsonManager;
|
||||
|
||||
JsonManager.createJsonFile("<File Name>");
|
||||
JsonManager.getJsonBody("<File Name>");
|
||||
JsonManager.updateJsonBody("<File Name>", 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
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.21</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
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."));
|
||||
```
|
||||
|
||||
35
pom.xml
Normal file
35
pom.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.hypple</groupId>
|
||||
<artifactId>EasyAPI</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<name>EasyAPI</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
18
src/main/java/net/hypple/EasyAPI/Bungee/Bungee.java
Normal file
18
src/main/java/net/hypple/EasyAPI/Bungee/Bungee.java
Normal file
@@ -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());
|
||||
}
|
||||
}
|
||||
57
src/main/java/net/hypple/EasyAPI/EasyAPI.java
Normal file
57
src/main/java/net/hypple/EasyAPI/EasyAPI.java
Normal file
@@ -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 <20>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());
|
||||
}
|
||||
}
|
||||
|
||||
83
src/main/java/net/hypple/EasyAPI/Json/JsonManager.java
Normal file
83
src/main/java/net/hypple/EasyAPI/Json/JsonManager.java
Normal file
@@ -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 <20>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 <20>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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
src/main/java/net/hypple/EasyAPI/Main.java
Normal file
10
src/main/java/net/hypple/EasyAPI/Main.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.hypple.EasyAPI;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
27
src/main/java/net/hypple/EasyAPI/RGB/HexColors.java
Normal file
27
src/main/java/net/hypple/EasyAPI/RGB/HexColors.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
51
src/main/java/net/hypple/EasyAPI/Regions/Region.java
Normal file
51
src/main/java/net/hypple/EasyAPI/Regions/Region.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
52
src/main/java/net/hypple/EasyAPI/Regions/Regions.java
Normal file
52
src/main/java/net/hypple/EasyAPI/Regions/Regions.java
Normal file
@@ -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<Region> regionsList = new ArrayList<>();
|
||||
|
||||
public static void addRegion(Region region) {
|
||||
regionsList.add(region);
|
||||
}
|
||||
|
||||
public static void deleteRegion(Region region) {
|
||||
regionsList.remove(region);
|
||||
}
|
||||
|
||||
public static List<Region> getRegionsByName(String name) {
|
||||
List<Region> reg = new ArrayList<>();
|
||||
for(Region region : regionsList) {
|
||||
if(region.getName().equals(name)) {
|
||||
reg.add(region);
|
||||
}
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
public static List<Region> getRegions() {
|
||||
return regionsList;
|
||||
}
|
||||
|
||||
public static List<Region> getRegionsInLocation(Location loc) {
|
||||
List<Region> 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;
|
||||
}
|
||||
}
|
||||
93
src/main/java/net/hypple/EasyAPI/mysql/EasyMySQL.java
Normal file
93
src/main/java/net/hypple/EasyAPI/mysql/EasyMySQL.java
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
BIN
target/classes/net/hypple/EasyAPI/Bungee/Bungee.class
Normal file
BIN
target/classes/net/hypple/EasyAPI/Bungee/Bungee.class
Normal file
Binary file not shown.
BIN
target/classes/net/hypple/EasyAPI/EasyAPI.class
Normal file
BIN
target/classes/net/hypple/EasyAPI/EasyAPI.class
Normal file
Binary file not shown.
BIN
target/classes/net/hypple/EasyAPI/Json/JsonManager.class
Normal file
BIN
target/classes/net/hypple/EasyAPI/Json/JsonManager.class
Normal file
Binary file not shown.
BIN
target/classes/net/hypple/EasyAPI/Main.class
Normal file
BIN
target/classes/net/hypple/EasyAPI/Main.class
Normal file
Binary file not shown.
BIN
target/classes/net/hypple/EasyAPI/RGB/HexColors.class
Normal file
BIN
target/classes/net/hypple/EasyAPI/RGB/HexColors.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/net/hypple/EasyAPI/Regions/Region.class
Normal file
BIN
target/classes/net/hypple/EasyAPI/Regions/Region.class
Normal file
Binary file not shown.
BIN
target/classes/net/hypple/EasyAPI/Regions/Regions.class
Normal file
BIN
target/classes/net/hypple/EasyAPI/Regions/Regions.class
Normal file
Binary file not shown.
BIN
target/classes/net/hypple/EasyAPI/mysql/EasyMySQL.class
Normal file
BIN
target/classes/net/hypple/EasyAPI/mysql/EasyMySQL.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user