Fixed /primerestart, member assign

Added handling for missing help text
Added autoassign member role
Handling missing permissions plugin (who knows)
Added unused Essentials dependency
This commit is contained in:
Norbi Peti 2018-06-01 02:08:20 +02:00
parent 4519d5f64a
commit d7accf5885
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
15 changed files with 59 additions and 66 deletions

View file

@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.github.TBMCPlugins.ButtonCore:Towny:master-v1.0-gc1751b8-228">
<library name="Maven: com.github.TBMCPlugins.ButtonCore:Towny:master-v1.0-g4519d5f-237">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-v1.0-gc1751b8-228/Towny-master-v1.0-gc1751b8-228.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-v1.0-g4519d5f-237/Towny-master-v1.0-g4519d5f-237.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-v1.0-gc1751b8-228/Towny-master-v1.0-gc1751b8-228-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-v1.0-g4519d5f-237/Towny-master-v1.0-g4519d5f-237-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-v1.0-gc1751b8-228/Towny-master-v1.0-gc1751b8-228-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-v1.0-g4519d5f-237/Towny-master-v1.0-g4519d5f-237-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: com.google.code.gson:gson:2.2.4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.2.4/gson-2.2.4-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.2.4/gson-2.2.4-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.ess3:Essentials:2.13.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/ess3/Essentials/2.13.1/Essentials-2.13.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/ess3/Essentials/2.13.1/Essentials-2.13.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/ess3/Essentials/2.13.1/Essentials-2.13.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.9-SNAPSHOT/bungeecord-chat-1.9-20160531.105416-38.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.9-SNAPSHOT/bungeecord-chat-1.9-20160531.105416-38-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.9-SNAPSHOT/bungeecord-chat-1.9-20160531.105416-38-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-20180527.071454-147.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-20180527.071454-147-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-20180527.071454-147-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: org.spigotmc:spigot-api:1.9.2-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.9.2-R0.1-SNAPSHOT/spigot-api-1.9.2-R0.1-20160507.064102-46.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.9.2-R0.1-SNAPSHOT/spigot-api-1.9.2-R0.1-20160507.064102-46-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.9.2-R0.1-SNAPSHOT/spigot-api-1.9.2-R0.1-20160507.064102-46-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: org.yaml:snakeyaml:1.15">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.15/snakeyaml-1.15.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.15/snakeyaml-1.15-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.15/snakeyaml-1.15-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -11,8 +11,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
<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: com.google.code.findbugs:annotations:2.0.1" level="project" />

View file

@ -87,6 +87,10 @@
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>ess-repo</id>
<url>http://repo.ess3.net/content/repositories/essrel/</url>
</repository>
</repositories>
<dependencies>
<dependency>
@ -145,6 +149,12 @@
<version>master-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId>
<version>2.13.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<organization>
<name>TBMCPlugins</name>

View file

@ -37,6 +37,8 @@ public class CommandCaller implements CommandExecutor {
else {
pc.setExecutor(instance);
String[] helptext = cmd.GetHelpText(topcmd);
if (helptext == null || helptext.length == 0)
throw new Exception("Command " + cmd.GetCommandPath() + " has no help text!");
pc.setUsage(helptext.length > 1 ? helptext[1] : helptext[0]);
}
}
@ -64,7 +66,7 @@ public class CommandCaller implements CommandExecutor {
}
return true;
}
if (cmd.isModOnly() && !MainPlugin.permission.has(sender, "tbmc.admin")) {
if (cmd.isModOnly() && (MainPlugin.permission != null ? !MainPlugin.permission.has(sender, "tbmc.admin") : !sender.isOp())) {
sender.sendMessage("§cYou need to be a mod to use this command.");
return true;
}

View file

@ -7,12 +7,14 @@ import buttondevteam.lib.chat.ChatRoom;
import buttondevteam.lib.chat.Color;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.player.TBMCPlayerBase;
import com.earth2me.essentials.Essentials;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@ -22,8 +24,10 @@ import java.util.logging.Logger;
public class MainPlugin extends JavaPlugin {
public static MainPlugin Instance;
@Nullable
public static Permission permission;
public static boolean Test;
public static Essentials ess;
private PluginDescriptionFile pdfFile;
private Logger logger;
@ -60,6 +64,7 @@ public class MainPlugin extends JavaPlugin {
} catch (IOException e) {
TBMCCoreAPI.SendException("Failed to write plugin list!", e);
}
ess = Essentials.getPlugin(Essentials.class);
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ") Test: " + Test + ".");
}

View file

@ -3,17 +3,30 @@ package buttondevteam.core;
import buttondevteam.lib.TBMCSystemChatEvent;
import buttondevteam.lib.player.TBMCPlayerBase;
import org.bukkit.Bukkit;
import org.bukkit.Statistic;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import static buttondevteam.core.MainPlugin.permission;
public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void OnPlayerJoin(PlayerJoinEvent event) {
TBMCPlayerBase.joinPlayer(event.getPlayer());
if (permission != null && !permission.playerInGroup(event.getPlayer(), "member")
&& (new Date(event.getPlayer().getFirstPlayed()).toInstant().plus(7, ChronoUnit.DAYS).isBefore(Instant.now())
|| event.getPlayer().getStatistic(Statistic.PLAY_ONE_TICK) > 20 * 3600 * 12)) {
permission.playerAddGroup(null, event.getPlayer(), "member");
event.getPlayer().sendMessage("§bYou are a member now. YEEHAW");
}
}
@EventHandler(priority = EventPriority.NORMAL)

View file

@ -28,6 +28,9 @@ public class PrimeRestartCommand extends TBMCCommandBase {
@Override
public String[] GetHelpText(String alias) {
return new String[0];
return new String[]{ //
"§6---- Prime restart ----", //
"Restarts the server as soon as nobody is online." //
};
}
}

View file

@ -71,7 +71,7 @@ public class Channel {
public static Function<CommandSender, RecipientTestResult> inGroupFilter(String permgroup) {
return noScoreResult(
s -> s.isOp() || (permgroup != null
? s instanceof Player && MainPlugin.permission.playerInGroup((Player) s, permgroup) : false),
? s instanceof Player && MainPlugin.permission != null && MainPlugin.permission.playerInGroup((Player) s, permgroup) : false),
"You need to be a(n) " + (permgroup != null ? permgroup : "OP") + " to use this channel.");
}

View file

@ -66,7 +66,7 @@ public class TBMCChatAPI {
if (cmd.getKey().startsWith(command + " ")) {
if (cmd.getValue().isPlayerOnly() && !(sender instanceof Player))
continue;
if (cmd.getValue().isModOnly() && !MainPlugin.permission.has(sender, "tbmc.admin"))
if (cmd.getValue().isModOnly() && (MainPlugin.permission != null ? !MainPlugin.permission.has(sender, "tbmc.admin") : !sender.isOp()))
continue;
int ind = cmd.getKey().indexOf(' ', command.length() + 2);
if (ind >= 0) {