mirror of
https://github.com/TotalFreedomMC/TF-Marriage.git
synced 2024-12-28 11:04:24 +00:00
Added a /marry seen command
This commit is contained in:
parent
6222161dfe
commit
7144d04f79
6 changed files with 103 additions and 2 deletions
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>me.lenis0012.mr</groupId>
|
||||
<artifactId>Marriage</artifactId>
|
||||
<version>1.10</version>
|
||||
<version>1.11</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Marriage</name>
|
||||
|
|
|
@ -23,6 +23,7 @@ public class MarryCMD implements CommandExecutor {
|
|||
commands.put("reload", new ReloadCommand());
|
||||
commands.put("sethome", new SethomeCommand());
|
||||
commands.put("tp", new TpCommand());
|
||||
commands.put("seen", new SeenCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
79
src/main/java/me/lenis0012/mr/commands/SeenCommand.java
Normal file
79
src/main/java/me/lenis0012/mr/commands/SeenCommand.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
package me.lenis0012.mr.commands;
|
||||
|
||||
import me.lenis0012.mr.MPlayer;
|
||||
import me.lenis0012.mr.PlayerConfig;
|
||||
import me.lenis0012.mr.lang.Messages;
|
||||
import me.lenis0012.mr.util.EcoUtil;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SeenCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
MPlayer mp = plugin.getMPlayer(player);
|
||||
Player op = Bukkit.getPlayer(mp.getPartner());
|
||||
|
||||
if(!mp.isMarried()) {
|
||||
error(player, Messages.NO_PARTNER);
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.eco) {
|
||||
double a = EcoUtil.getPriceFromConfig("seen");
|
||||
if(a != 0.0) {
|
||||
if(EcoUtil.withrawMoneyIfEnough(player, a)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerConfig pc = plugin.getPlayerConfig(mp.getPartner());
|
||||
String msg = Messages.OFFLINE_SINCE;
|
||||
if(op != null && op.isOnline())
|
||||
msg = Messages.ONLINE_SINCE;
|
||||
|
||||
String type = Messages.SECONDS;
|
||||
long time = System.currentTimeMillis();
|
||||
if(op != null && op.isOnline())
|
||||
time -= pc.getLong("last-login");
|
||||
else
|
||||
time -= pc.getLong("last-logout");
|
||||
time = time / 1000;
|
||||
if(time >= 60) {
|
||||
time = time / 60;
|
||||
type = Messages.MINUTES;
|
||||
} if(time >= 60) {
|
||||
time = time / 60;
|
||||
type = Messages.HOURS;
|
||||
} if(time >= 24) {
|
||||
time = time / 24;
|
||||
type = Messages.DAYS;
|
||||
} if(time >= 7) {
|
||||
time = time / 7;
|
||||
type = Messages.WEEKS;
|
||||
} if(time >= 4) {
|
||||
time = time / 4;
|
||||
type = Messages.MONTHS;
|
||||
} if(time > 12) {
|
||||
time = time / 12;
|
||||
type = Messages.YEARS;
|
||||
}
|
||||
|
||||
msg = msg.replace("{TIME}", time + " " + type);
|
||||
inform(player, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "marry.seen";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playersOnly() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -29,9 +29,18 @@ public class Messages {
|
|||
public static final String PARTNER_SETHOME = lang.getMessageWithDefault("partner sethome", "Your partner has set your home!");
|
||||
public static final String PARTNER_TELEPORTING = lang.getMessageWithDefault("partner teleporting", "Your partner is teleporting to you!");
|
||||
public static final String GIFT_CREATIVE = lang.getMessageWithDefault("gift creative", "You may not gift items in creative!");
|
||||
public static final String OFFLINE_SINCE = lang.getMessageWithDefault("offline since", "Your partner is offline since {TIME}");
|
||||
public static final String ONLINE_SINCE = lang.getMessageWithDefault("online since", "Your partner is online since");
|
||||
|
||||
/** Words */
|
||||
public static final String PAGE = lang.getWordWithDefault("page", "Page");
|
||||
public static final String PARTNERS = lang.getWordWithDefault("partners", "Partners");
|
||||
public static final String TELEPORTING = lang.getWordWithDefault("teleporting", "Teleporting");
|
||||
public static final String SECONDS = lang.getWordWithDefault("seconds", "sec");
|
||||
public static final String MINUTES = lang.getWordWithDefault("seconds", "min");
|
||||
public static final String HOURS = lang.getWordWithDefault("seconds", "hours");
|
||||
public static final String DAYS = lang.getWordWithDefault("days", "days");
|
||||
public static final String WEEKS = lang.getWordWithDefault("weeks", "weeks");
|
||||
public static final String MONTHS = lang.getWordWithDefault("months", "months");
|
||||
public static final String YEARS = lang.getWordWithDefault("years", "years");
|
||||
}
|
|
@ -16,6 +16,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
|
||||
|
@ -98,6 +99,17 @@ public class PlayerListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
MPlayer mp = plugin.getMPlayer(player);
|
||||
mp.getConfig().set("last-logout", System.currentTimeMillis());
|
||||
mp.getConfig().save();
|
||||
plugin.clearPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
MPlayer mp = plugin.getMPlayer(player);
|
||||
mp.getConfig().set("last-login", System.currentTimeMillis());
|
||||
mp.getConfig().save();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
name: Marriage
|
||||
version: 1.10
|
||||
version: 1.11
|
||||
main: me.lenis0012.mr.Marriage
|
||||
author: lenis0012
|
||||
description: A plugin wich provides the function to start a relationship in minecraft.
|
||||
|
|
Loading…
Reference in a new issue