Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luck
committed
May 22, 2016
0 parents
commit dc1e06e
Showing
70 changed files
with
4,044 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# built application files | ||
*.jar | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Local configuration file (sdk path, etc) | ||
logs/ | ||
|
||
# Eclipse project files | ||
.classpath | ||
.project | ||
|
||
# Intellij project files | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# Gradle | ||
.gradletasknamecache | ||
.gradle/ | ||
build/ | ||
bin/ | ||
gradle/ | ||
gradlew* | ||
|
||
# Maven | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 Luck | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# LuckPerms | ||
A quite possibly shit™ permissions implementation for Bukkit/BungeeCord. | ||
|
||
### Why? | ||
Yeah, I don't know. There are other more advanced, optimized, better programmed and thoroughly tested alternative plugins around, you should probably use those instead. I just wanted some specific features, and something that was compatible with BungeeCord. | ||
|
||
### Features | ||
- **Group inheritance** - users can be members of multiple groups, groups can inherit other groups | ||
- **Multi-server support** - data is synced across all servers/platforms | ||
- **Per-server permissions/groups** - define permissions that only apply on certain servers | ||
- **Vault Support** - hooks into Vault to integrate with other plugins | ||
- **Everything is configured using commands** - no editing yml files, yuck | ||
- **Efficient** - maybe? Who knows, it might be. | ||
- **BungeeCord compatible** - my main motive for making this was that all other Bungee/Bukkit compatible perms plugins are utter aids. (At least, I couldn't find any decent ones) | ||
|
||
### Caveats | ||
- Only supports MySQL | ||
- Not at all tested and could be super unreliable | ||
- It's quite possibly shit™ | ||
|
||
So, not anything major, really ¯\ _(ツ)_ /¯ | ||
|
||
### Commands | ||
Command usage is printed when you supply too little arguments. | ||
|
||
Bukkit: `/luckperms` `/perms` `/permissions` `/lp` `/perm` | ||
|
||
Bungee: `/luckpermsbungee` `/bperms` `/bpermissions` `/lpb` `/bperm` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?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"> | ||
<parent> | ||
<artifactId>luckperms</artifactId> | ||
<groupId>me.lucko</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>luckperms-bukkit</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>LuckPerms</name> | ||
|
||
<build> | ||
<defaultGoal>clean package</defaultGoal> | ||
<finalName>LuckPerms</finalName> | ||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.3</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<minimizeJar>true</minimizeJar> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<!-- BukkitAPI --> | ||
<dependency> | ||
<groupId>org.bukkit</groupId> | ||
<artifactId>bukkit</artifactId> | ||
<version>1.8.8-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- Vault --> | ||
<dependency> | ||
<groupId>net.milkbowl.vault</groupId> | ||
<artifactId>VaultAPI</artifactId> | ||
<version>1.5</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- LuckPerms Common --> | ||
<dependency> | ||
<groupId>me.lucko</groupId> | ||
<artifactId>luckperms-common</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package me.lucko.luckperms; | ||
|
||
import me.lucko.luckperms.utils.LPConfiguration; | ||
import org.bukkit.configuration.InvalidConfigurationException; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class BukkitConfig implements LPConfiguration { | ||
private final LPBukkitPlugin plugin; | ||
private YamlConfiguration configuration; | ||
|
||
public BukkitConfig(LPBukkitPlugin plugin) { | ||
this.plugin = plugin; | ||
create(); | ||
} | ||
|
||
private void create() { | ||
File configFile = new File(plugin.getDataFolder(), "config.yml"); | ||
|
||
if (!configFile.exists()) { | ||
configFile.getParentFile().mkdirs(); | ||
plugin.saveResource("config.yml", false); | ||
} | ||
|
||
configuration = new YamlConfiguration(); | ||
|
||
try { | ||
configuration.load(configFile); | ||
|
||
} catch (InvalidConfigurationException | IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public String getServer() { | ||
return configuration.getString("server"); | ||
} | ||
|
||
@Override | ||
public String getPrefix() { | ||
return configuration.getString("prefix"); | ||
} | ||
|
||
@Override | ||
public int getSyncTime() { | ||
return configuration.getInt("sql.sync-minutes"); | ||
} | ||
|
||
@Override | ||
public String getDefaultGroupNode() { | ||
return "luckperms.group." + configuration.getString("default-group"); | ||
} | ||
|
||
@Override | ||
public String getDefaultGroupName() { | ||
return configuration.getString("default-group"); | ||
} | ||
|
||
@Override | ||
public boolean getIncludeGlobalPerms() { | ||
return configuration.getBoolean("include-global"); | ||
} | ||
|
||
@Override | ||
public String getDatabaseValue(String value) { | ||
return configuration.getString("sql." + value); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
bukkit/src/main/java/me/lucko/luckperms/CommandManagerBukkit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package me.lucko.luckperms; | ||
|
||
import me.lucko.luckperms.commands.CommandManager; | ||
import me.lucko.luckperms.commands.Sender; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import java.util.Arrays; | ||
|
||
class CommandManagerBukkit extends CommandManager implements CommandExecutor { | ||
CommandManagerBukkit(LuckPermsPlugin plugin) { | ||
super(plugin); | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
return onCommand(new Sender() { | ||
@Override | ||
public void sendMessage(String s) { | ||
sender.sendMessage(s); | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(String node) { | ||
return sender.hasPermission(node); | ||
} | ||
}, Arrays.asList(args)); | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
bukkit/src/main/java/me/lucko/luckperms/LPBukkitPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package me.lucko.luckperms; | ||
|
||
import lombok.Getter; | ||
import me.lucko.luckperms.data.Datastore; | ||
import me.lucko.luckperms.data.DatastoreConfiguration; | ||
import me.lucko.luckperms.data.HikariDatastore; | ||
import me.lucko.luckperms.groups.GroupManager; | ||
import me.lucko.luckperms.listeners.PlayerListener; | ||
import me.lucko.luckperms.runnables.UpdateTask; | ||
import me.lucko.luckperms.users.BukkitUserManager; | ||
import me.lucko.luckperms.users.UserManager; | ||
import me.lucko.luckperms.utils.LPConfiguration; | ||
import net.milkbowl.vault.permission.Permission; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.PluginCommand; | ||
import org.bukkit.plugin.PluginManager; | ||
import org.bukkit.plugin.RegisteredServiceProvider; | ||
import org.bukkit.plugin.ServicePriority; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.Arrays; | ||
import java.util.UUID; | ||
|
||
@Getter | ||
public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { | ||
public static final String VERSION = "v1.0"; | ||
|
||
private LPConfiguration configuration; | ||
private UserManager userManager; | ||
private GroupManager groupManager; | ||
private Datastore datastore; | ||
|
||
@Override | ||
public void onEnable() { | ||
configuration = new BukkitConfig(this); | ||
|
||
// register events | ||
PluginManager pm = Bukkit.getPluginManager(); | ||
pm.registerEvents(new PlayerListener(this), this); | ||
|
||
// register commands | ||
CommandManagerBukkit commandManager = new CommandManagerBukkit(this); | ||
PluginCommand main = getServer().getPluginCommand("luckperms"); | ||
main.setExecutor(commandManager); | ||
main.setAliases(Arrays.asList("perms", "lp", "permissions", "p", "perm")); | ||
|
||
datastore = new HikariDatastore(this); | ||
datastore.init(new DatastoreConfiguration( | ||
configuration.getDatabaseValue("address"), | ||
configuration.getDatabaseValue("database"), | ||
configuration.getDatabaseValue("username"), | ||
configuration.getDatabaseValue("password") | ||
)); | ||
|
||
userManager = new BukkitUserManager(this); | ||
groupManager = new GroupManager(this); | ||
|
||
int mins = getConfiguration().getSyncTime(); | ||
if (mins > 0) { | ||
long ticks = mins * 60 * 20; | ||
new UpdateTask(this).runTaskTimer(this, ticks, ticks); | ||
} | ||
|
||
// Provide vault support | ||
try { | ||
if (getServer().getPluginManager().isPluginEnabled("Vault")) { | ||
getServer().getServicesManager().register(Permission.class, new VaultHook(this), this, ServicePriority.High); | ||
getLogger().info("Registered Vault permission hook."); | ||
} else { | ||
getLogger().info("Vault not found."); | ||
} | ||
} catch (Exception e) { | ||
getLogger().warning("Error whilst hooking into Vault."); | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void doAsync(Runnable r) { | ||
Bukkit.getScheduler().runTaskAsynchronously(this, r); | ||
} | ||
|
||
@Override | ||
public void doSync(Runnable r) { | ||
Bukkit.getScheduler().runTask(this, r); | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return VERSION; | ||
} | ||
|
||
@Override | ||
public String getPlayerStatus(UUID uuid) { | ||
if (getServer().getPlayer(uuid) != null) return "&aOnline"; | ||
return "&cOffline"; | ||
} | ||
|
||
@Override | ||
public int getPlayerCount() { | ||
return getServer().getOnlinePlayers().size(); | ||
} | ||
|
||
@Override | ||
public void runUpdateTask() { | ||
new UpdateTask(this).runTask(this); | ||
} | ||
} |
Oops, something went wrong.