This commit is contained in:
speed 2020-06-15 17:39:52 -04:00 committed by GitHub
parent b02b46e27b
commit 82cf99c03c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 323 additions and 0 deletions

32
TFGuilds.iml Normal file
View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.15-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.12" level="project" />
</component>
</module>

82
pom.xml Normal file
View file

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.tf</groupId>
<artifactId>TFGuilds</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>TFGuilds</name>
<description>Plugin which allows for players to make their own guilds on the server</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,36 @@
package totalfreedom.tfguilds;
import org.bukkit.plugin.java.JavaPlugin;
import totalfreedom.tfguilds.command.GuildCommand;
import totalfreedom.tfguilds.config.Config;
import totalfreedom.tfguilds.util.GLog;
public final class TFGuilds extends JavaPlugin
{
public static TFGuilds plugin;
public Config config;
public Config guilds;
@Override
public void onEnable()
{
plugin = this;
enableCommands();
config = new Config(plugin, "config.yml");
guilds = new Config(plugin, "guilds.yml");
GLog.info("Enabled");
}
@Override
public void onDisable()
{
config.save();
guilds.save();
GLog.info("Disabled");
}
private void enableCommands()
{
this.getCommand("guild").setExecutor(new GuildCommand());
}
}

View file

@ -0,0 +1,34 @@
package totalfreedom.tfguilds.command;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import totalfreedom.tfguilds.util.GBase;
import totalfreedom.tfguilds.util.GUtil;
public class GuildCommand extends GBase implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length != 2)
{
return false;
}
if (args[0].toLowerCase().equals("create"))
{
if (GUtil.isConsole(sender))
{
sender.sendMessage(ChatColor.RED + "You are not allowed to run this command.");
return true;
}
GUtil.createGuild(sender, args[1]);
sender.sendMessage(ChatColor.GREEN + "Successfully created a guild named " + args[1]);
return true;
}
return false;
}
}

View file

@ -0,0 +1,49 @@
package totalfreedom.tfguilds.config;
import org.bukkit.configuration.file.YamlConfiguration;
import totalfreedom.tfguilds.TFGuilds;
import java.io.File;
public class Config extends YamlConfiguration
{
private final TFGuilds plugin;
private final File file;
public Config(TFGuilds plugin, String name)
{
this.plugin = plugin;
this.file = new File(plugin.getDataFolder(), name);
if (!file.exists())
{
options().copyDefaults(true);
plugin.saveResource(name, false);
}
load();
}
public void load()
{
try
{
super.load(file);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void save()
{
try
{
super.save(file);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,8 @@
package totalfreedom.tfguilds.util;
import totalfreedom.tfguilds.TFGuilds;
public class GBase
{
protected static TFGuilds plugin = TFGuilds.plugin;
}

View file

@ -0,0 +1,30 @@
package totalfreedom.tfguilds.util;
import java.util.logging.Level;
import java.util.logging.Logger;
public class GLog
{
private static final Logger log = Logger.getLogger("Minecraft");
private static final String prefix = "[TFGuilds] ";
private static void log(String s, Level l)
{
log.log(l, prefix + s);
}
public static void info(String s)
{
log(s, Level.INFO);
}
public static void warn(String s)
{
log(s, Level.WARNING);
}
public static void severe(String s)
{
log(s, Level.SEVERE);
}
}

View file

@ -0,0 +1,35 @@
package totalfreedom.tfguilds.util;
import lombok.Getter;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import totalfreedom.tfguilds.TFGuilds;
import java.util.List;
public class GUtil
{
public static TFGuilds plugin = TFGuilds.plugin;
@Getter
public static String[] guildName;
public static boolean isConsole(CommandSender sender)
{
return sender instanceof ConsoleCommandSender;
}
public static void createGuild(CommandSender owner, String guildName)
{
plugin.guilds.set("guilds." + guildName, guildName);
plugin.guilds.set("guilds." + guildName + ".owner", owner.getName());
plugin.guilds.set("guilds." + guildName + ".members", owner.getName());
List<String> players = plugin.guilds.getStringList("guilds." + guildName + ".members");
players.add(owner.getName());
plugin.guilds.set("guilds." + guildName + ".members", players);
plugin.guilds.save();
GLog.info(owner.getName() + " has created a new guild: " + guildName);
}
}

View file

@ -0,0 +1 @@
# TFGuilds Configuration File

View file

@ -0,0 +1,5 @@
# Guilds
# <name>:
# <owner>: speednt
# <members>:
# - speednt

View file

@ -0,0 +1,11 @@
name: TFGuilds
version: ${project.version}
main: totalfreedom.tfguilds.TFGuilds
api-version: 1.13
authors: [speednt]
description: Plugin which allows for players to make their own guilds on the server
commands:
guild:
description: Main command for TFGuilds, allows for creating your own guild
usage: /<command> <create> <name>
aliases: [g]