Initial commit

This commit is contained in:
2017-03-19 01:47:09 +01:00
commit f677c3040a
28 changed files with 684 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package net.DeltaWings.Minecraft.BetterTP.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
* Created by Delta Wings on 19/03/2017 at.01:40
*/
public class Bettertp implements CommandExecutor {
@Override
public boolean onCommand(CommandSender s, Command c, String l, String[] a) {
if(a.length == 2) {
if(a[0].equalsIgnoreCase("set")) {
if(a[1].equalsIgnoreCase("spawn")) {
} else if(a[1].equalsIgnoreCase("lobby")) {
}
} else if(a[0].equalsIgnoreCase("del") || a[0].equalsIgnoreCase("delete")) {
if(a[1].equalsIgnoreCase("spawn")) {
} else if(a[1].equalsIgnoreCase("lobby")) {
}
}
} else if(a.length == 1) {
if(a[0].equalsIgnoreCase("help")) {
}
}
return false;
}
}

View File

@ -0,0 +1,9 @@
package net.DeltaWings.Minecraft.BetterTP.Commands;
import org.bukkit.command.CommandExecutor;
/**
* Created by Delta Wings on 19/03/2017 at.01:37
*/
public class Delhome implements CommandExecutor {
}

View File

@ -0,0 +1,9 @@
package net.DeltaWings.Minecraft.BetterTP.Commands;
import org.bukkit.command.CommandExecutor;
/**
* Created by Delta Wings on 19/03/2017 at.01:37
*/
public class Home implements CommandExecutor {
}

View File

@ -0,0 +1,15 @@
package net.DeltaWings.Minecraft.BetterTP.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
* Created by Delta Wings on 18/03/2017 at.15:24
*/
public class Lobby implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
}

View File

@ -0,0 +1,9 @@
package net.DeltaWings.Minecraft.BetterTP.Commands;
import org.bukkit.command.CommandExecutor;
/**
* Created by Delta Wings on 19/03/2017 at.01:37
*/
public class Sethome implements CommandExecutor {
}

View File

@ -0,0 +1,34 @@
package net.DeltaWings.Minecraft.BetterTP.Commands;
import net.DeltaWings.Minecraft.BetterTP.Custom.Config;
import net.DeltaWings.Minecraft.BetterTP.Main;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Spawn implements CommandExecutor {
Config m = new Config("", "messages");
@Override
public boolean onCommand(CommandSender s, Command abdoulila, String l, String[] a) {
if(s instanceof Player) {
if(s.hasPermission("bettertp.spawn")) {
Config c = new Config("data/spawn", "config");
if(c.exist()) {
Double y = c.getDouble("x", (double) -1);
if(!(y == -1)) {
String[] sl = new String[2];
sl[0] = "spawn";
Main.getInstance().tp(sl, (Player) s );
}
}
} else s.sendMessage(m.getString("global.permission"));
} else {
s.sendMessage(m.getString("global.not-console"));
}
return false;
}
}

View File

@ -0,0 +1,118 @@
package net.DeltaWings.Minecraft.BetterTP.Custom;
import net.DeltaWings.Minecraft.BetterTP.Main;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Config {
private final FileConfiguration config;
private final File root = Main.getInstance().getDataFolder();
private final File folder;
private final File file;
private final FileManager fm = new FileManager();
public Config(String folder, String file) {
this.folder = new File(folder);
this.file = new File(root.toString() + File.separator + this.folder.toString() + File.separator + file + ".yml");
config = YamlConfiguration.loadConfiguration(this.file);
}
public Boolean exist() {
return file.exists();
}
public void set(String path, Object value) {
config.set(path, value);
}
public void set(String path) {
config.createSection(path);
}
public void header(String header) {
config.options().header(header);
}
public int getInt(String path, Integer def) {
return config.getInt(path, def);
}
public int getInt(String path) {
return config.getInt(path);
}
public Double getDouble(String path, Double def) {
return config.getDouble(path, def);
}
public Double getDouble(String path) {
return config.getDouble(path);
}
public String getString(String path, String def) {
return config.getString(path, def);
}
public String getString(String path) {
return config.getString(path);
}
public Long getLong(String path) {
return config.getLong(path);
}
public Long getLong(String path, Long def) {
return config.getLong(path, def);
}
public void save() {
try {
config.save(file);
} catch ( IOException e ) {
e.printStackTrace();
}
}
public ArrayList<String> getSection(String path) {
return new ArrayList<>(config.getConfigurationSection(path).getKeys(false));
}
public List<String> getStringList(String path) {
return config.getStringList(path);
}
public void create() {
if(!exist()) {
if(!root.exists()) root.mkdirs();
File rfolder = new File(root.toString() + File.separator + folder.toString());
if(!rfolder.exists()) rfolder.mkdirs();
try {
file.createNewFile();
} catch ( IOException e ) {
e.printStackTrace();
}
}
}
public boolean isSet(String path) {
return config.isSet(path);
}
public boolean getBoolean(String path, Boolean def) {
return config.getBoolean(path, def);
}
public boolean getBoolean(String path) {
return config.getBoolean(path);
}
public void delete() {
fm.delete(file);
}
}

View File

@ -0,0 +1,55 @@
package net.DeltaWings.Minecraft.BetterTP.Custom;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class FileManager {
public List<String> listFiles(String path) {
String[] t = new File(path).list();
if(t == null) return null;
else return Arrays.asList(t);
}
public List<String> listFiles(File path) {
String[] t = path.list();
if(t == null) return null;
else return Arrays.asList(t);
}
public void delete(File path) {
path.delete();
}
public void delete(String path) {
File file = new File(path);
file.delete();
}
public void createFile(String path) {
try {
new File(path).createNewFile();
} catch ( IOException e ) {
e.printStackTrace();
}
}
public void createFile(File path) {
try {
path.createNewFile();
} catch ( IOException e ) {
e.printStackTrace();
}
}
public void createFolder(File path) {
path.mkdirs();
}
public void createFolder(String path) {
new File(path).mkdirs();
}
}

View File

@ -0,0 +1,70 @@
package net.DeltaWings.Minecraft.BetterTP;
import net.DeltaWings.Minecraft.BetterTP.Commands.*;
import net.DeltaWings.Minecraft.BetterTP.Custom.Config;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Level;
public final class Main extends JavaPlugin {
public void log(String Message) {
Bukkit.getLogger().log(Level.INFO, Message);
}
public Boolean tp(String[] Type, Player Player) {
if(Type[0].equals("spawn")) {
Config c = new Config("data/spawn", "config");
return Player.teleport(new Location(Bukkit.getServer().getWorld(c.getString("world")), c.getDouble("x"), c.getDouble("y"), c.getDouble("z")));
} else {
Config c = new Config("data", Player.getName());
String t = Type[1];
return Player.teleport(new Location(Bukkit.getServer().getWorld(c.getString(t+"world")), c.getDouble(t+"x"), c.getDouble(t+"y"), c.getDouble(t+"z")));
}
}
private static Main instance;
public static Main getInstance() {
return instance;
}
@Override
public void onEnable() {
instance = this;
getCommand("Spawn").setExecutor(new Spawn());
getCommand("Lobby").setExecutor(new Lobby());
getCommand("Home").setExecutor(new Home());
getCommand("Bettertp").setExecutor(new Bettertp());
getCommand("Sethome").setExecutor(new Sethome());
getCommand("Delhome").setExecutor(new Delhome());
config();
log("Plugin Loaded !");
}
@Override
public void onDisable() {
log("Plugin Unloaded !");
}
private void config() {
Config messages = new Config("", "messages");
if(!messages.exist()) {
messages.create();
messages.set("global.permission", "&8 > &cYou do not have the permission to do thats !");
messages.set("global.not-console", "This Command cannot be send throught console");
messages.set("spawn.set", "&8 >&c The Spawn was set");
messages.set("spawn.teleported", "&8 >&c You have benn teleported to the spawn");
messages.set("home.teleported", "&8 >&c You have benn teleported to you home : [home]");
messages.set("home.set", "&8 >&c Your home [home] has been set");
messages.save();
}
}
}