Merge pull request #50 from TBMCPlugins/dev
Primerestart is silent by default, loud when it has a parameter, added /member command
This commit is contained in:
commit
8d3b6b642a
8 changed files with 95 additions and 29 deletions
11
.idea/inspectionProfiles/Project_Default.xml
Normal file
11
.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="false" />
|
||||||
|
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="false" />
|
||||||
|
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
|
||||||
|
<disabledExtension id="moduleInfo" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
|
@ -1,13 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Maven: com.github.milkbowl:VaultAPI:master-8dc0859cba-1">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/milkbowl/VaultAPI/master-8dc0859cba-1/VaultAPI-master-8dc0859cba-1.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/milkbowl/VaultAPI/master-8dc0859cba-1/VaultAPI-master-8dc0859cba-1-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/milkbowl/VaultAPI/master-8dc0859cba-1/VaultAPI-master-8dc0859cba-1-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -13,6 +13,7 @@
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||||
|
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class MainPlugin extends JavaPlugin {
|
||||||
TBMCChatAPI.AddCommand(this, UpdatePluginCommand.class);
|
TBMCChatAPI.AddCommand(this, UpdatePluginCommand.class);
|
||||||
TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class);
|
TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class);
|
||||||
TBMCChatAPI.AddCommand(this, PrimeRestartCommand.class);
|
TBMCChatAPI.AddCommand(this, PrimeRestartCommand.class);
|
||||||
|
TBMCChatAPI.AddCommand(this, MemberCommand.class);
|
||||||
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
|
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
|
||||||
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);
|
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);
|
||||||
TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null));
|
TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null));
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package buttondevteam.core;
|
||||||
|
|
||||||
|
import buttondevteam.lib.chat.CommandClass;
|
||||||
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
|
import lombok.val;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@CommandClass(modOnly = true, path = "member")
|
||||||
|
public class MemberCommand extends TBMCCommandBase {
|
||||||
|
@Override
|
||||||
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
|
if (args.length < 2)
|
||||||
|
return false;
|
||||||
|
final boolean add;
|
||||||
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
|
add = true;
|
||||||
|
else if (args[0].equalsIgnoreCase("remove"))
|
||||||
|
add = false;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> {
|
||||||
|
if (MainPlugin.permission == null) {
|
||||||
|
sender.sendMessage("§cError: No permission plugin found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
val op = Bukkit.getOfflinePlayer(args[1]);
|
||||||
|
if (!op.hasPlayedBefore()) {
|
||||||
|
sender.sendMessage("§cCannot find player or haven't played before.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (add) {
|
||||||
|
if (MainPlugin.permission.playerAddGroup(null, op, "member"))
|
||||||
|
sender.sendMessage("§b" + op.getName() + " added as a member!");
|
||||||
|
else
|
||||||
|
sender.sendMessage("§cFailed to add " + op.getName() + " as a member!");
|
||||||
|
} else {
|
||||||
|
if (MainPlugin.permission.playerRemoveGroup(null, op, "member"))
|
||||||
|
sender.sendMessage("§b" + op.getName() + " removed as a member!");
|
||||||
|
else
|
||||||
|
sender.sendMessage("§bFailed to remove " + op.getName() + " as a member!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] GetHelpText(String alias) {
|
||||||
|
return new String[]{ //
|
||||||
|
"06---- Member ----", //
|
||||||
|
"Add or remove server members.", //
|
||||||
|
"Usage: /member <add|remove> <player>" //
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,11 +40,13 @@ public class PlayerListener implements Listener {
|
||||||
&& !event.getQuitMessage().equalsIgnoreCase("Server closed")
|
&& !event.getQuitMessage().equalsIgnoreCase("Server closed")
|
||||||
&& !event.getQuitMessage().equalsIgnoreCase("Server is restarting")) {
|
&& !event.getQuitMessage().equalsIgnoreCase("Server is restarting")) {
|
||||||
if (Bukkit.getOnlinePlayers().size() <= 1) {
|
if (Bukkit.getOnlinePlayers().size() <= 1) {
|
||||||
Bukkit.broadcastMessage("§cNobody is online anymore. Restarting.");
|
if (PrimeRestartCommand.isLoud())
|
||||||
|
Bukkit.broadcastMessage("§cNobody is online anymore. Restarting.");
|
||||||
Bukkit.spigot().restart();
|
Bukkit.spigot().restart();
|
||||||
} else if (!(event.getPlayer() instanceof IDiscordSender) && System.nanoTime() - 10 * 1000000000L - lasttime > 0) { //Ten seconds passed since last reminder
|
} else if (!(event.getPlayer() instanceof IDiscordSender) && System.nanoTime() - 10 * 1000000000L - lasttime > 0) { //Ten seconds passed since last reminder
|
||||||
lasttime = System.nanoTime();
|
lasttime = System.nanoTime();
|
||||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online.");
|
if (PrimeRestartCommand.isLoud())
|
||||||
|
Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,26 +11,33 @@ import org.bukkit.command.CommandSender;
|
||||||
public class PrimeRestartCommand extends TBMCCommandBase {
|
public class PrimeRestartCommand extends TBMCCommandBase {
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
loud = args.length > 0;
|
||||||
sender.sendMessage("§bPlayers online, restart delayed.");
|
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online.");
|
sender.sendMessage("§bPlayers online, restart delayed.");
|
||||||
plsrestart = true;
|
if (loud)
|
||||||
} else {
|
Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online.");
|
||||||
sender.sendMessage("§bNobody is online. Restarting now.");
|
plsrestart = true;
|
||||||
Bukkit.broadcastMessage("§cNobody is online. Restarting server.");
|
} else {
|
||||||
Bukkit.spigot().restart();
|
sender.sendMessage("§bNobody is online. Restarting now.");
|
||||||
}
|
if (loud)
|
||||||
return true;
|
Bukkit.broadcastMessage("§cNobody is online. Restarting server.");
|
||||||
|
Bukkit.spigot().restart();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean plsrestart = false;
|
private static boolean plsrestart = false;
|
||||||
|
@Getter
|
||||||
|
private static boolean loud = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias) {
|
public String[] GetHelpText(String alias) {
|
||||||
return new String[]{ //
|
return new String[]{ //
|
||||||
"§6---- Prime restart ----", //
|
"§6---- Prime restart ----", //
|
||||||
"Restarts the server as soon as nobody is online." //
|
"Restarts the server as soon as nobody is online.", //
|
||||||
|
"To be loud, type something after, like /primerestart lol (it doesn't matter what you write)", //
|
||||||
|
"To be silent, don't type anything" //
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,3 +11,5 @@ commands:
|
||||||
description: Restarts the server as soon as nobody is online.
|
description: Restarts the server as soon as nobody is online.
|
||||||
randomtp:
|
randomtp:
|
||||||
description: teleport player to random location within world border. Every five players teleport to the same general area, and then a new general area is randomly selected for the next five players.
|
description: teleport player to random location within world border. Every five players teleport to the same general area, and then a new general area is randomly selected for the next five players.
|
||||||
|
member:
|
||||||
|
description: Add or remove a member
|
Loading…
Reference in a new issue