Archived
Private
Public Access
1
0

Initial commit

This commit is contained in:
2022-09-04 12:45:01 +02:00
commit f4a01d6a69
11601 changed files with 4206660 additions and 0 deletions

113
Plugins/Old/API/.gitignore vendored Normal file
View File

@@ -0,0 +1,113 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Common working directory
run/

74
Plugins/Old/API/pom.xml Normal file
View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.craftix</groupId>
<artifactId>API</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>API</name>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,42 @@
package de.craftix.api;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
public final class API extends JavaPlugin {
private static API instance;
private static final ArrayList<MySQL> sqlConnections = new ArrayList<>();
private static boolean spawnCmd = true;
private static boolean gamemodeCmd = true;
private static boolean defaultListener = false;
public static void setSpawnCmd(boolean spawnCmd) {
API.spawnCmd = spawnCmd;
}
public static void setGamemodeCmd(boolean gamemodeCmd) {
API.gamemodeCmd = gamemodeCmd;
}
public static void setDefaultListener(boolean defaultListener) {
API.defaultListener = defaultListener;
}
@Override
public void onEnable() {
instance = this;
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
if (spawnCmd) new Spawn(this);
if (gamemodeCmd) new Gamemode(this);
if (defaultListener) Bukkit.getPluginManager().registerEvents(new DefaultListener(), this);
}, 20);
}
@Override
public void onDisable() {
for (MySQL all : sqlConnections) all.disconnect();
}
public static API getInstance() { return instance; }
public static ArrayList<MySQL> getSqlConnections() { return sqlConnections; }
}

View File

@@ -0,0 +1,72 @@
package de.craftix.api;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.ArrayList;
public class CfgLocationManager {
protected FileConfiguration config;
protected String prefix;
public CfgLocationManager(FileConfiguration config, String prefix) {
this.config = config;
this.prefix = prefix;
}
private int getNextID() {
int id = 0;
while (id <= 100) {
if (config.contains(prefix + "." + id)) id++;
else return id;
}
return -1;
}
public void setLocation(Location loc) {
int id = getNextID();
String currPrefix = prefix + "." + id + ".";
config.set(currPrefix + ".World", loc.getWorld().getName());
config.set(currPrefix + ".X", loc.getX());
config.set(currPrefix + ".Y", loc.getY());
config.set(currPrefix + ".Z", loc.getZ());
config.set(currPrefix + ".Yaw", loc.getYaw());
config.set(currPrefix + ".Pitch", loc.getPitch());
try { config.save(config.getCurrentPath()); }
catch (Exception e) { e.printStackTrace(); }
}
public Location getLocation(int id) {
if (!config.contains(prefix + "." + id)) return null;
World w = Bukkit.getWorld(config.getString(prefix + "." + id + ".World"));
double x = config.getDouble(prefix + "." + id + ".X");
double y = config.getDouble(prefix + "." + id + ".Y");
double z = config.getDouble(prefix + "." + id + ".Z");
float yaw = Float.parseFloat(config.getString(prefix + "." + id + ".Yaw"));
float pitch = Float.parseFloat(config.getString(prefix + "." + id + ".Pitch"));
return new Location(w, x, y, z, yaw, pitch);
}
public Location[] getLocations(int... ids) {
Location[] locs = new Location[ids.length];
for (int i = 0; i < ids.length; i++) {
locs[i] = getLocation(ids[i]);
}
return locs;
}
public Location[] getLocations() {
ArrayList<Location> locs = new ArrayList<>();
int id = -1;
while (id <= 100) {
id++;
if (getLocation(id) == null) continue;
locs.add(getLocation(id));
}
return locs.toArray(new Location[0]);
}
}

View File

@@ -0,0 +1,44 @@
package de.craftix.api;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class Contact {
public static void sendActionBar(Player p, String msg) {
IChatBaseComponent base = IChatBaseComponent.ChatSerializer.a("{\"text\": \"\"}").a(msg);
PacketPlayOutChat chat = new PacketPlayOutChat(base, (byte) 2);
CraftPlayer cp = (CraftPlayer)p;
cp.getHandle().playerConnection.sendPacket(chat);
}
public static void sendTitle(Player p, String title, int fadeIn, int stay, int fadeOut) {
IChatBaseComponent base = IChatBaseComponent.ChatSerializer.a("{\"text\": \"\"}").a(title);
PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, base);
PacketPlayOutTitle length = new PacketPlayOutTitle(fadeIn, stay, fadeOut);
((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
((CraftPlayer) p).getHandle().playerConnection.sendPacket(length);
}
public static void sendTitle(Player p, String title, String subtitle, int fadeIn, int stay, int fadeOut) {
sendTitle(p, title, fadeIn, stay, fadeOut);
sendSubtitle(p, subtitle, fadeIn, stay, fadeOut);
}
public static void sendSubtitle(Player p, String subtitle, int fadeIn, int stay, int fadeOut) {
IChatBaseComponent base = IChatBaseComponent.ChatSerializer.a("{\"text\": \"\"}").a(subtitle);
PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, base);
PacketPlayOutTitle length = new PacketPlayOutTitle(fadeIn, stay, fadeOut);
((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
((CraftPlayer) p).getHandle().playerConnection.sendPacket(length);
}
}

View File

@@ -0,0 +1,76 @@
package de.craftix.api;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
public class DefaultListener implements Listener {
private static boolean weather = true;
private static String joinMSG = "§ePlayer joined the game";
private static String quitMSG = "§ePlayer left the game";
private static String deathMSG = "Player died";
private static boolean canDestroyBlock = true;
private static boolean canPlaceBlock = true;
private static boolean canInteract = true;
private static boolean canInteractAtEntity = true;
public static void setWeather(boolean weather) {
DefaultListener.weather = weather;
Bukkit.getWorlds().forEach(world -> world.setStorm(false));
Bukkit.getWorlds().forEach(world -> world.setThundering(false));
}
public static void setJoinMSG(String joinMSG) {
DefaultListener.joinMSG = joinMSG;
}
public static void setQuitMSG(String quitMSG) {
DefaultListener.quitMSG = quitMSG;
}
public static void setDeathMSG(String deathMSG) {
DefaultListener.deathMSG = deathMSG;
}
public static void setCanDestroyBlock(boolean canDestroyBlock) {
DefaultListener.canDestroyBlock = canDestroyBlock;
}
public static void setCanPlaceBlock(boolean canPlaceBlock) {
DefaultListener.canPlaceBlock = canPlaceBlock;
}
public static void setCanInteract(boolean canInteract) {
DefaultListener.canInteract = canInteract;
}
public static void setCanInteractAtEntity(boolean canInteractAtEntity) {
DefaultListener.canInteractAtEntity = canInteractAtEntity;
}
@EventHandler
public void onWeather(WeatherChangeEvent event) { event.setCancelled(!weather); }
@EventHandler
public void onBreak(BlockBreakEvent event) { event.setCancelled(!canDestroyBlock); }
@EventHandler
public void onPlace(BlockPlaceEvent event) { event.setCancelled(!canPlaceBlock); }
@EventHandler
public void onInteract(PlayerInteractEvent event) { event.setCancelled(!canInteract); }
@EventHandler
public void onInteractEntity(PlayerInteractAtEntityEvent event) { event.setCancelled(!canInteractAtEntity); }
@EventHandler
public void onJoin(PlayerJoinEvent event) { event.setJoinMessage(joinMSG.replace("Player", event.getPlayer().getDisplayName())); }
@EventHandler
public void onQuit(PlayerQuitEvent event) { event.setQuitMessage(quitMSG.replace("Player", event.getPlayer().getDisplayName())); }
@EventHandler
public void onDeath(PlayerDeathEvent event) { event.setDeathMessage(deathMSG.replace("Player", event.getEntity().getDisplayName())); }
}

View File

@@ -0,0 +1,51 @@
package de.craftix.api;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Gamemode implements CommandExecutor {
public Gamemode(JavaPlugin plugin) {
PluginCommand cmd = plugin.getCommand("gm");
cmd.setPermission("minecraft.command.gamemode");
cmd.setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (!(sender instanceof Player)) return true;
Player p = (Player) sender;
Player t = null;
if (args.length == 1) t = p;
else {
t = Bukkit.getPlayer(args[1]);
if (t == null) {
p.sendMessage("§cDieser Spieler existiert nicht!");
return true;
}
}
if (args[0].equals("0") || args[0].equals("s") || args[0].equalsIgnoreCase("survival")) {
t.setGameMode(GameMode.SURVIVAL);
t.sendMessage("§aDu bist nun im §6Überlebensmodus§a.");
}
if (args[0].equals("1") || args[0].equalsIgnoreCase("c") || args[0].equalsIgnoreCase("creative")) {
t.setGameMode(GameMode.CREATIVE);
t.sendMessage("§aDu bist nun im §6Creativmodus§a.");
}
if (args[0].equals("2") || args[0].equalsIgnoreCase("a") || args[0].equalsIgnoreCase("adventure")) {
t.setGameMode(GameMode.ADVENTURE);
t.sendMessage("§aDu bist nun im §6Adventuremodus§a.");
}
if (args[0].equals("3") || args[0].equals("S") || args[0].equalsIgnoreCase("spectator")) {
t.setGameMode(GameMode.SPECTATOR);
t.sendMessage("§aDu bist nun im §6Spectatormodus§a.");
}
return false;
}
}

View File

@@ -0,0 +1,111 @@
package de.craftix.api;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class ItemBuilder {
public Material material;
public String name;
public int amount = 1;
public short damage = 0;
public HashMap<Enchantment, Integer> enchantments = new HashMap<>();
public ArrayList<String> lore = new ArrayList<>();
public boolean showEnchantments = true;
public boolean isSkull = false;
public OfflinePlayer player;
public ItemBuilder(Material mat){
material = mat;
}
public ItemBuilder(Material mat, int amount){
material = mat;
this.amount = amount;
}
public ItemBuilder(Material mat, int amount, int damage){
material = mat;
this.amount = amount;
this.damage = (short) damage;
}
public ItemBuilder(OfflinePlayer player) {
this.player = player;
isSkull = true;
}
public ItemBuilder(OfflinePlayer player, int amount) {
this.player = player;
this.amount = amount;
isSkull = true;
}
public ItemBuilder setName(String name){
this.name = name;
return this;
}
public ItemBuilder addEnchantment(Enchantment e, int level){
enchantments.put(e, level);
return this;
}
public ItemBuilder showEnchantments(boolean value) {
showEnchantments = value;
return this;
}
public ItemBuilder setLore(String... lore){
this.lore.addAll(Arrays.asList(lore));
return this;
}
public ItemBuilder setGlowing(boolean value) {
if (value) {
enchantments.put(Enchantment.DURABILITY, 1);
showEnchantments = false;
}else {
enchantments.clear();
showEnchantments = true;
}
return this;
}
public ItemStack create(){
ItemStack item;
if (!isSkull) {
item = new ItemStack(material, amount, damage);
ItemMeta meta = item.getItemMeta();
for (Enchantment e : enchantments.keySet()){
meta.addEnchant(e, enchantments.get(e), true);
}
meta.setLore(lore);
meta.setDisplayName(name);
if (!showEnchantments) meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
}else {
item = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
SkullMeta meta = (SkullMeta) item.getItemMeta();
meta.setOwner(player.getName());
for (Enchantment e : enchantments.keySet()){
meta.addEnchant(e, enchantments.get(e), true);
}
meta.setLore(lore);
meta.setDisplayName(name);
if (!showEnchantments) meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
}
return item;
}
}

View File

@@ -0,0 +1,121 @@
package de.craftix.api;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class ItemEditor {
public ItemStack item;
public Material material;
public String name;
public int amount;
public short damage;
public HashMap<Enchantment, Integer> enchantments;
public ArrayList<String> lore;
public boolean showEnchantments;
public boolean isSkull;
public OfflinePlayer player;
public ItemEditor(ItemStack item) {
this.item = item;
this.material = item.getType();
this.name = item.getItemMeta().getDisplayName();
this.amount = item.getAmount();
this.damage = item.getDurability();
this.enchantments = (HashMap<Enchantment, Integer>) item.getEnchantments();
this.lore = (ArrayList<String>) item.getItemMeta().getLore();
this.showEnchantments = !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS);
this.isSkull = (item.getType() == Material.SKULL_ITEM);
if (isSkull) player = Bukkit.getOfflinePlayer(((SkullMeta) item.getItemMeta()).getOwner());
}
public ItemEditor setMaterial(Material material) {
this.material = material;
return this;
}
public ItemEditor setAmount(int amount) {
this.amount = amount;
return this;
}
public ItemEditor setDamage(int damage) {
this.damage = (short) damage;
return this;
}
public ItemEditor setSkull(OfflinePlayer player) {
isSkull = true;
material = Material.SKULL_ITEM;
damage = 3;
return this;
}
public ItemEditor setName(String name){
this.name = name;
return this;
}
public ItemEditor addEnchantment(Enchantment e, int level){
enchantments.put(e, level);
return this;
}
public ItemEditor showEnchantments(boolean value) {
showEnchantments = value;
return this;
}
public ItemEditor setLore(String... lore){
this.lore.addAll(Arrays.asList(lore));
return this;
}
public ItemEditor setGlowing(boolean value) {
if (value) {
enchantments.put(Enchantment.DURABILITY, 1);
showEnchantments = false;
}else {
enchantments.clear();
showEnchantments = true;
}
return this;
}
public ItemStack edit(){
if (!isSkull) {
item = new ItemStack(material, amount, damage);
ItemMeta meta = item.getItemMeta();
for (Enchantment e : enchantments.keySet()){
meta.addEnchant(e, enchantments.get(e), true);
}
meta.setLore(lore);
meta.setDisplayName(name);
if (!showEnchantments) meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
}else {
item = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
SkullMeta meta = (SkullMeta) item.getItemMeta();
meta.setOwner(player.getName());
for (Enchantment e : enchantments.keySet()){
meta.addEnchant(e, enchantments.get(e), true);
}
meta.setLore(lore);
meta.setDisplayName(name);
if (!showEnchantments) meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
}
return item;
}
}

View File

@@ -0,0 +1,85 @@
package de.craftix.api;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import java.sql.ResultSet;
import java.util.ArrayList;
public class LocationSaver {
protected MySQL con;
protected String tableName;
public LocationSaver(MySQL con, String tableName) {
this.con = con;
this.tableName = tableName;
if (!con.isConnected()) con.connect();
con.insert("CREATE TABLE IF NOT EXISTS " + tableName + " (ID INT(10), X VARCHAR(100), Y VARCHAR(100), Z VARCHAR(100), Yaw VARCHAR(100), Pitch VARCHAR(100), World VARCHAR(100))");
}
protected int getNextID() {
try {
ResultSet rs = con.getData("SELECT * FROM " + tableName);
int id = 0;
while (rs.next()) if (rs.getInt("ID") == id) id++;
return id;
}catch (Exception ignored) {}
return -1;
}
public int saveLocation(Location loc) {
try {
int id = getNextID();
String qry1 = "INSERT INTO " + tableName + " (ID, X, Y, Z, Yaw, Pitch, World) VALUES (";
String qry2 = id + ", \"" + loc.getX() + "\", \"" + loc.getY() + "\", \"" + loc.getZ() + "\", ";
String qry3 = "\"" + loc.getYaw() + "\", \"" + loc.getPitch() + "\", \"" + loc.getWorld().getName() + "\")";
con.insert(qry1 + qry2 + qry3);
return id;
}catch (Exception ignored) {}
return -1;
}
public Location getLocation(int id) {
try {
ResultSet rs = con.getData("SELECT * FROM " + tableName + " WHERE ID = " + id);
if (!rs.next()) return null;
double x = Double.parseDouble(rs.getString("X"));
double y = Double.parseDouble(rs.getString("Y"));
double z = Double.parseDouble(rs.getString("Z"));
float yaw = Float.parseFloat(rs.getString("Yaw"));
float pitch = Float.parseFloat(rs.getString("Pitch"));
World world = Bukkit.getWorld(rs.getString("World"));
return new Location(world, x, y, z, yaw, pitch);
}catch (Exception ignored) {}
return null;
}
public Location[] getLocations(int... ids) {
Location[] locs = new Location[ids.length];
for (int i = 0; i < ids.length; i++) {
locs[i] = getLocation(ids[i]);
}
return locs;
}
public Location[] getLocations() {
try {
ArrayList<Location> locs = new ArrayList<>();
ResultSet rs = con.getData("SELECT * FROM " + tableName);
while (rs.next()) {
double x = Double.parseDouble(rs.getString("X"));
double y = Double.parseDouble(rs.getString("Y"));
double z = Double.parseDouble(rs.getString("Z"));
float yaw = Float.parseFloat(rs.getString("Yaw"));
float pitch = Float.parseFloat(rs.getString("Pitch"));
World world = Bukkit.getWorld(rs.getString("World"));
locs.add(new Location(world, x, y, z, yaw, pitch));
}
return locs.toArray(new Location[0]);
}catch (Exception ignored) {}
return new Location[0];
}
}

View File

@@ -0,0 +1,67 @@
package de.craftix.api;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
public class MySQL {
public String server;
public int port;
public String database;
public String username;
public String password;
protected Connection con;
public MySQL() {
API.getSqlConnections().add(this);
}
public boolean connect(){
String conString = "jdbc:mysql://" + server + ":" + port + "/" + database;
try {
con = DriverManager.getConnection(conString, username, password);
System.out.println("[ArenaFight] MySQL connected");
return true;
}catch (SQLException e){
System.out.println("[ArenaFight] MySQL connection failed");
return false;
}
}
public boolean disconnect(){
if (!isConnected()) return true;
try {
con.close();
con = null;
System.out.println("[ArenaFight] MySQL disconnected");
return true;
}catch (SQLException e){
System.out.println("[ArenaFight] MySQL disconnecting failed");
return false;
}
}
public boolean isConnected(){
return con != null;
}
public void insert(String qry){
try {
con.prepareStatement(qry).executeUpdate();
}catch (SQLException e){
e.printStackTrace();
}
}
public ResultSet getData(String qry){
try {
return con.prepareStatement(qry).executeQuery();
}catch (SQLException e){
e.printStackTrace();
return null;
}
}
}

View File

@@ -0,0 +1,88 @@
package de.craftix.api;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Spawn implements CommandExecutor {
public Spawn(JavaPlugin plugin) {
plugin.getCommand("spawn").setExecutor(this);
PluginCommand setSpawn = plugin.getCommand("setspawn");
setSpawn.setPermission("utils.setspawn");
setSpawn.setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (command.getName().equalsIgnoreCase("spawn")) {
if (!(sender instanceof Player)) return true;
if (!isSet()) return true;
teleport((Player) sender);
return false;
}else {
if (!(sender instanceof Player)) return true;
if (!sender.hasPermission("utils.setspawn")) return true;
setLocation(((Player) sender).getLocation());
sender.sendMessage("§aDer Spawn wurde erfolgreich gesetzt!");
}
return true;
}
public static void teleport(Player p){
FileConfiguration config = API.getInstance().getConfig();
if (!config.contains("Spawn.World")) return;
World world = Bukkit.getWorld(config.getString("Spawn.World"));
double x = config.getDouble("Spawn.X");
double y = config.getDouble("Spawn.Y");
double z = config.getDouble("Spawn.Z");
float yaw = (float) config.getDouble("Spawn.Yaw");
float pitch = (float) config.getDouble("Spawn.Pitch");
Location spawn = new Location(world, x, y, z, yaw, pitch);
p.teleport(spawn);
}
public static Location getLocation(){
FileConfiguration config = API.getInstance().getConfig();
if (!config.contains("Spawn.World")) return null;
World world = Bukkit.getWorld(config.getString("Spawn.World"));
double x = config.getDouble("Spawn.X");
double y = config.getDouble("Spawn.Y");
double z = config.getDouble("Spawn.Z");
float yaw = (float) config.getDouble("Spawn.Yaw");
float pitch = (float) config.getDouble("Spawn.Pitch");
return new Location(world, x, y, z, yaw, pitch);
}
public static void setLocation(Location loc){
FileConfiguration config = API.getInstance().getConfig();
config.set("Spawn.World", loc.getWorld().getName());
if (loc.getBlockX() > 0) config.set("Spawn.X", loc.getBlockX() + 0.5);
else config.set("Spawn.X", loc.getBlockX() - 0.5);
config.set("Spawn.Y", loc.getBlockY() + 2);
if (loc.getBlockZ() > 0) config.set("Spawn.Z", loc.getBlockZ() + 0.5);
else config.set("Spawn.Z", loc.getBlockZ() - 0.5);
config.set("Spawn.Yaw", loc.getYaw());
config.set("Spawn.Pitch", loc.getPitch());
API.getInstance().saveConfig();
}
public static boolean isSet() {
return API.getInstance().getConfig().contains("Spawn.World");
}
}

View File

@@ -0,0 +1,8 @@
name: API
version: ${project.version}
main: de.craftix.api.API
commands:
spawn:
setspawn:
gm: