mirror of
https://github.com/Aviortheking/Marriage.git
synced 2025-04-22 10:52:16 +00:00
WIP
This commit is contained in:
parent
99baa00706
commit
f10ed5443a
10
.idea/artifacts/Marriage.xml
generated
Normal file
10
.idea/artifacts/Marriage.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="Marriage">
|
||||
<output-path>$PROJECT_DIR$/Mariage/tests/plugins</output-path>
|
||||
<root id="archive" name="Marriage.jar">
|
||||
<element id="module-output" name="Mariage" />
|
||||
<element id="file-copy" path="$PROJECT_DIR$/Mariage/src/config.yml" />
|
||||
<element id="file-copy" path="$PROJECT_DIR$/Mariage/src/plugin.yml" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
13
.idea/libraries/ressources.xml
generated
Normal file
13
.idea/libraries/ressources.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="ressources">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/Mariage/ressources" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/Mariage/ressources" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/Mariage/ressources" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/Mariage/ressources" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file:///production/Mariage" />
|
||||
<output-test url="file:///test/Mariage" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/ressources" type="java-resource" />
|
||||
@ -9,5 +11,6 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="ressources" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -1,22 +1,25 @@
|
||||
config:
|
||||
#time to let the player answer
|
||||
timeout: 60
|
||||
isbroadcasted: true
|
||||
|
||||
messages:
|
||||
proposition: "Dear %receiver%, \nWould you like to marry me ? \nFrom %sender%. \n(You have %time% seconds to send your answer !) \n(use '/marry accept %player%' to accept the proposition)"
|
||||
miss-spell: "&cYou have miss-spelled somethings !"
|
||||
no-proposition: "&cThe &8%player% &chasn't sended a proposition"
|
||||
accepted: you have accepted the proposition !
|
||||
broadcast: "&c %p1% has been married with %p2% !"
|
||||
already-married: "&cSorry, but you are already married with someone."
|
||||
proposition: Dear %receiver%, \nWould you like to marry me ? \nFrom %sender%. \n\(You have %time% seconds to send your answer !\) \n\(use '/marry accept %player%' to accept the proposition\)
|
||||
# don't touch under this !!!
|
||||
partners: #each players have the sames infos !
|
||||
player:
|
||||
married: false #is the player married ?
|
||||
who: Aviortheking #name of the partner
|
||||
who: none #name of the partner
|
||||
propositions:
|
||||
otherplayer:
|
||||
isblocked: true
|
||||
timeout: 60
|
||||
home: # coords of the home
|
||||
x: 0
|
||||
y: 0
|
||||
z: 0
|
||||
world: world
|
||||
propositions:
|
||||
otherplayer: #other player name
|
||||
isblocked: true #if blocked the player won't receive a proposition !
|
||||
timeout: 60 # time before the proposition stop while at 0 the other player can reinvite if not blocked
|
||||
|
||||
|
||||
world: world
|
@ -1,6 +1,7 @@
|
||||
package net.DeltaWings.Minecraft.Marriage;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
@ -10,10 +11,13 @@ public class Main extends JavaPlugin implements Listener{
|
||||
|
||||
public void onEnable(){
|
||||
getCommand("Marry").setExecutor(new Marry(this));
|
||||
getCommand("Partner").setExecutor(new Partner(this));
|
||||
|
||||
//load the config
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvents(new PlayerJoin(this), this);
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
@ -14,10 +14,12 @@ import net.DeltaWings.Minecraft.Marriage.Main;
|
||||
*/
|
||||
public class Marry implements CommandExecutor {
|
||||
|
||||
private Main pl;
|
||||
private FileConfiguration config;
|
||||
|
||||
Marry(Main main) {
|
||||
this.config = main.getConfig();
|
||||
this.pl = main;
|
||||
this.config = pl.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -25,6 +27,7 @@ public class Marry implements CommandExecutor {
|
||||
if(sender instanceof Player) {
|
||||
Player p = (Player)sender;
|
||||
if(cmd.getName().equalsIgnoreCase("marry")) {
|
||||
// /marry <player> to ask a player to marry him/her
|
||||
if(args.length == 1 && !args[0].equalsIgnoreCase("accept")) {
|
||||
Boolean found = false;
|
||||
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
@ -40,16 +43,30 @@ public class Marry implements CommandExecutor {
|
||||
//send message "Player isn't online or is not correctly typed"
|
||||
p.sendMessage(args[0]+" isn't online or you haven't correctly typed his/her name !");
|
||||
}
|
||||
// /marry accept <player>
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("accept")) {
|
||||
if(config.getInt("partners."+p.getName()+".propositions."+args[1]+".timeout", 0) > 0) {
|
||||
//message you have accepted the proposition
|
||||
//bd %couple has been married !
|
||||
} else {
|
||||
//message the other player haven't send a proposition or the proposition is timed out !
|
||||
}
|
||||
if (!config.getString("partners." + p.getName() + ".who").equalsIgnoreCase("none"))
|
||||
p.sendMessage((config.getString("messages.already-married").replace("&", "§")));
|
||||
else if (config.getConfigurationSection("partners." + p.getName() + ".propositions").contains(args[1])) {
|
||||
String conf = "partners." + p.getName() + ".";
|
||||
config.set(conf + "who", args[1]);
|
||||
config.set(conf + "propositions", null);
|
||||
p.sendMessage(config.getString("messages.accepted"));
|
||||
if (config.getBoolean("config.isbroadcasted"))
|
||||
Bukkit.broadcastMessage(config.getString("messages.broadcast").replace("&", "§").replace("%p1%", p.getName()).replace("%p2%", args[1]));
|
||||
} else p.sendMessage(config.getString("messages.no-proposition").replace("%player%", args[1]).replace("&", "§"));
|
||||
//check si marrié
|
||||
//msg t'es déjà marrié sale con !
|
||||
//sinon check si le joueur lui a proposée
|
||||
//message you have accepted the proposition
|
||||
//bd %p1 and %p2 has been married !
|
||||
//sinon message le joueur ne t'a pas proposée de te marrié avc lui/elle
|
||||
} else {
|
||||
p.sendMessage(config.getString("messages.miss-spell").replace("&", "§"));
|
||||
}
|
||||
}
|
||||
}
|
||||
pl.saveConfig();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
55
Mariage/src/net/DeltaWings/Minecraft/Marriage/Partner.java
Normal file
55
Mariage/src/net/DeltaWings/Minecraft/Marriage/Partner.java
Normal file
@ -0,0 +1,55 @@
|
||||
package net.DeltaWings.Minecraft.Marriage;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Delta Wings on 02/01/2017 at.23:35
|
||||
*/
|
||||
public class Partner implements CommandExecutor {
|
||||
|
||||
private Main pl;
|
||||
private FileConfiguration config;
|
||||
|
||||
Partner(Main main) {
|
||||
this.pl = main;
|
||||
this.config = pl.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (cmd.getName().equalsIgnoreCase("partner")) {
|
||||
/**
|
||||
* infos/info
|
||||
* join
|
||||
* sethome/shome
|
||||
* home
|
||||
* delhome/dhome
|
||||
* message/msg
|
||||
* sendgift/gift
|
||||
*/
|
||||
if (args.length == 1 && (args[0].equalsIgnoreCase("infos") || args[0].equalsIgnoreCase("info"))) {
|
||||
// /partner infos
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("join")) {
|
||||
// /partner join
|
||||
} else if (args.length == 1 && (args[0].equalsIgnoreCase("sethome") || args[0].equalsIgnoreCase("shome"))) {
|
||||
// /partner sethome/shome
|
||||
} else if (args.length == 1 && (args[0].equalsIgnoreCase("home"))) {
|
||||
// /partner home
|
||||
} else if (args.length == 1 && (args[0].equalsIgnoreCase("delhome") || args[0].equalsIgnoreCase("dhome"))) {
|
||||
// /partner delhome/dhome
|
||||
} else if (args.length == 1 && (args[0].equalsIgnoreCase("message") || args[0].equalsIgnoreCase("msg"))) {
|
||||
// /partner message/msg
|
||||
} else if (args.length == 1 && (args[0].equalsIgnoreCase("sendgift") || args[0].equalsIgnoreCase("gift"))) {
|
||||
// /partner sendgift/gift
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package net.DeltaWings.Minecraft.Marriage;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
/**
|
||||
* Created by Delta Wings on 02/01/2017 at.20:37
|
||||
*/
|
||||
public class PlayerJoin implements Listener {
|
||||
|
||||
private Main pl;
|
||||
private FileConfiguration config;
|
||||
|
||||
PlayerJoin(Main main) {
|
||||
this.pl = main;
|
||||
this.config = pl.getConfig();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoinEvent(PlayerJoinEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
String Base = "partners."+p.getName();
|
||||
if(!p.hasPlayedBefore()) {
|
||||
config.createSection(Base);
|
||||
config.createSection(Base+".who");
|
||||
config.set(Base+".who", "none");
|
||||
config.createSection(Base+".propositions");
|
||||
|
||||
} else if (!config.isSet(Base)) {
|
||||
config.createSection(Base);
|
||||
config.createSection(Base+".who");
|
||||
config.set(Base+".who", "none");
|
||||
config.createSection(Base+".propositions");
|
||||
}
|
||||
pl.saveConfig();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user