mirror of
https://github.com/Aviortheking/Marriage.git
synced 2025-04-22 10:52:16 +00:00
Rework in progress
This commit is contained in:
parent
f2f0afc78a
commit
c85fc6afc2
@ -0,0 +1,21 @@
|
||||
package net.DeltaWings.Minecraft.Marriage.Commands;
|
||||
|
||||
import net.DeltaWings.Minecraft.Marriage.Custom.Config;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Delta Wings on 22/03/2017 at.00:52
|
||||
*/
|
||||
public class CmdGen {
|
||||
private Config c = new Config("", "config");
|
||||
private Config d = new Config("", "data");
|
||||
|
||||
|
||||
public void sendMessage(Player Player, String Message) {
|
||||
Player.sendMessage((c.getString("prefix") + Message).replace("&", "§"));
|
||||
}
|
||||
|
||||
public Boolean isMarried(String Player1, String Player2) {
|
||||
return d.getString(Player1 + ".marry").equalsIgnoreCase(Player2);
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package net.DeltaWings.Minecraft.Marriage.Custom;
|
||||
|
||||
import net.DeltaWings.Minecraft.Marriage.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 String version = "1.0.0";
|
||||
|
||||
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() {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
public String version() {
|
||||
return version;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package net.DeltaWings.Minecraft.Marriage;
|
||||
|
||||
import net.DeltaWings.Minecraft.Marriage.Custom.Config;
|
||||
import net.DeltaWings.Minecraft.Marriage.Events.PlayerJoin;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -13,8 +14,15 @@ import java.util.List;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
|
||||
public static Main getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static Main instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
// Plugin startup logic
|
||||
getCommand("Marry").setExecutor(new Marry(this));
|
||||
getCommand("Partner").setExecutor(new Partner(this));
|
||||
@ -25,6 +33,8 @@ public final class Main extends JavaPlugin {
|
||||
saveConfig();
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvents(new PlayerJoin(this), this);
|
||||
|
||||
config();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -32,6 +42,14 @@ public final class Main extends JavaPlugin {
|
||||
// Plugin shutdown logic
|
||||
}
|
||||
|
||||
private void config() {
|
||||
Config c = new Config("", "config");
|
||||
if(!c.exist()) {
|
||||
c.create();
|
||||
c.set("prefix", "&8[&bMarriage&8]&f");
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean hasPermission(Command command, String[] arguments, Player player) {
|
||||
List<String> perms = new ArrayList<>();
|
||||
perms.add("deltawings.marriage.all");
|
||||
@ -55,3 +73,111 @@ public final class Main extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
couples.yml
|
||||
|
||||
Aviortheking:
|
||||
marry: LePhoenixArdent
|
||||
home:
|
||||
world:
|
||||
x:
|
||||
y:
|
||||
z:
|
||||
requests:
|
||||
tepenny: blocked
|
||||
seb23100: {time remaining}
|
||||
|
||||
fonctionnement:
|
||||
/marry <(i)invite (a)accept or (h)help or null> <playername or null>
|
||||
/partner <null or (he)help or (ho)home or (sh, shome)sethome or (dh, dhome)delhome or (tp)teleport>
|
||||
|
||||
/divorce <playername or null or (h)help>
|
||||
|
||||
/divorce help || /divorce
|
||||
send message to sender message config.intro
|
||||
send message to sender message (desc of /marry fonctions)
|
||||
send message to sneder message config.outro
|
||||
|
||||
/divorce player
|
||||
if sender.marry != player
|
||||
send message to sender your are not married with player
|
||||
else
|
||||
set home to null
|
||||
set marry to null
|
||||
if player is online
|
||||
send message to player sender have divorced with you
|
||||
send message to sender you have divorced with player
|
||||
|
||||
|
||||
|
||||
/marry invite player
|
||||
if player.marry == null
|
||||
if player.requests.sender is blocked
|
||||
send message to sender you are blocked
|
||||
else if player.requests.sender have remaining remaining
|
||||
send message to sender time is remaining before you can re ask
|
||||
else
|
||||
send message to sender you have invited player
|
||||
send message to player you have been invited by sender
|
||||
set player.invitations.sender time + 60s
|
||||
else
|
||||
send message to sender you are already married
|
||||
|
||||
|
||||
|
||||
/marry accept player
|
||||
if sender.invitations.player < time && sender.married == none
|
||||
set sender.marry to player
|
||||
set sender.requests to null
|
||||
set player.marry to sender
|
||||
set player.requests to null
|
||||
send message to player message you and sender are now married
|
||||
send message to sender message you and player are now married
|
||||
if config.broadcast
|
||||
send message to server message sender and player are now married
|
||||
else
|
||||
send message to sender you don't answered in time or didn't received any request
|
||||
|
||||
/marry help || /marry
|
||||
send message to sender message config.intro
|
||||
send message to sender message (desc of /marry fonctions)
|
||||
send message to sender message config.outro
|
||||
|
||||
/partner || /partner help
|
||||
send message to sender message config.intro
|
||||
send message to sender message (desc of /partner fonctions)
|
||||
send message to sneder message config.outro
|
||||
|
||||
/partner sethome
|
||||
if sender.home.y is not set
|
||||
sender.home.world = sender.world
|
||||
sender.home.x = sender.x
|
||||
sender.home.y = sender.y
|
||||
sender.home.z = sender.z
|
||||
etc etc
|
||||
sender.marry.home.world = sender.world
|
||||
sender.marry.home.x = sender.x
|
||||
sender.marry.home.y = sender.y
|
||||
sender.marry.home.z = sender.z
|
||||
send message to sender && sender.marry your home has been set
|
||||
else
|
||||
send message to sender you already have a home
|
||||
|
||||
/partner home
|
||||
if sender.home is set
|
||||
sender.teleport to sender.home
|
||||
send message to sender you have been teleported to your home
|
||||
|
||||
/partner delhome
|
||||
if sender.home.y is set
|
||||
set sender.home to null
|
||||
send message to sender && sender.marry your home has been deleted
|
||||
else
|
||||
send message to sender you don't have any homes
|
||||
|
||||
/partner tp
|
||||
if sender.marry is online
|
||||
sender.teleport to sender.marry
|
||||
else
|
||||
send message to sender your partner isn't online
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user