Skip to content

Commit

Permalink
Split the project into 3 parts : Core, Bukkit and Sponge.
Browse files Browse the repository at this point in the history
Core contains the main plugin logic, Bukkit stands for the Bukkit plugin and Sponge for the Sponge plugin.
  • Loading branch information
Skyost committed Nov 25, 2018
1 parent 1c160f1 commit 1f617c1
Show file tree
Hide file tree
Showing 86 changed files with 6,348 additions and 2,031 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -25,7 +25,7 @@ You can open, close or destroy the door only if you have the corresponding key i

## Documentation
A documentation is available [here](https://dev.bukkit.org/projects/serial-key/pages/documentation).
Keep in mind that this documentation is for the **v0.4** of this plugin !
Keep in mind that this documentation is for the **v1.0** of this plugin !

## Videos
You can find all videos [here](https://dev.bukkit.org/projects/serial-key/pages/videos).
Expand Down
108 changes: 2 additions & 106 deletions build.gradle
@@ -1,107 +1,3 @@
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0'
id 'java'
id 'maven'
}

group = 'fr.skyost.serialkey'
version = '0.4.1'

sourceCompatibility = 1.8

bukkit {
name = 'SerialKey'
main = 'fr.skyost.serialkey.SerialKey'
description = 'Lock your chests and doors.'
author = 'Skyost'
website = 'http://dev.bukkit.org/bukkit-plugins/serial-key/'
apiVersion = '1.13'

commands {
serialkey {
description = 'Main command of SerialKey.'
aliases = ['serial-key', 'sk']
usage = '/serialkey getkey.'
}
}

permissions {
'serialkey.*' {
setDefault('OP')
description = 'Gives you all plugin\'s permissions'
children = [
'serialkey.craft.key',
'serialkey.craft.masterkey',
'serialkey.craft.keyclone',
'serialkey.craft.bunchofkeys',
'serialkey.craft.padlockfinder',
'serialkey.use.key',
'serialkey.use.masterkey',
'serialkey.use.bunchofkeys',
'serialkey.use.padlockfinder',
'serialkey.command.getkey',
]
}
'serialkey.craft.key' {
setDefault('TRUE')
description = 'Allows you to craft a key.'
}
'serialkey.craft.masterkey' {
setDefault('OP')
description = 'Allows you to craft a master key.'
}
'serialkey.craft.keyclone' {
setDefault('TRUE')
description = 'Allows you to clone a key.'
}
'serialkey.craft.bunchofkeys' {
setDefault('TRUE')
description = 'Allows you to bunch of keys.'
}
'serialkey.craft.padlockfinder' {
setDefault('TRUE')
description = 'Allows you to craft a padlock finder.'
}
'serialkey.use.key' {
setDefault('TRUE')
description = 'Allows you to use a key.'
}
'serialkey.use.masterkey' {
setDefault('OP')
description = 'Allows you to use a master key.'
}
'serialkey.use.bunchofkeys' {
setDefault('TRUE')
description = 'Allows you to use a bunch of keys.'
}
'serialkey.use.padlockfinder' {
setDefault('TRUE')
description = 'Allows you to use a padlock finder.'
}
'serialkey.command.getkey' {
setDefault('OP')
description = 'Allows you to use /serialkey getkey.'
}
}
}

repositories {
mavenCentral()
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'http://nexus.hc.to/content/repositories/pub_releases' }
maven { url = 'http://repo.bstats.org/content/repositories/releases/' }
}

dependencies {
compileOnly 'org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT'
compile 'org.bstats:bstats-bukkit-lite:1.2'
}

shadowJar {
destinationDir = new File(rootProject.projectDir, 'build/release/')
version = project.version
configurations = [project.configurations.compile]
mergeServiceFiles()
relocate 'org.bstats.bukkit', 'fr.skyost.serialkey.util.bstats'
subprojects {
group = 'fr.skyost.serialkey'
}
105 changes: 105 additions & 0 deletions bukkit/build.gradle
@@ -0,0 +1,105 @@
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0'
id 'java'
id 'maven'
}

version = '1.0'
sourceCompatibility = 1.8

bukkit {
name = 'SerialKey'
main = 'fr.skyost.serialkey.bukkit.SerialKey'
description = 'Lock your chests and doors.'
author = 'Skyost'
website = 'http://dev.bukkit.org/bukkit-plugins/serial-key/'
apiVersion = '1.13'

commands {
serialkey {
description = 'Main command of SerialKey.'
aliases = ['serial-key', 'sk']
usage = '/serialkey getkey.'
}
}

permissions {
'serialkey.*' {
setDefault('OP')
description = 'Gives you all plugin\'s permissions'
children = [
'serialkey.craft.key',
'serialkey.craft.masterkey',
'serialkey.craft.keyclone',
'serialkey.craft.bunchofkeys',
'serialkey.craft.padlockfinder',
'serialkey.use.key',
'serialkey.use.masterkey',
'serialkey.use.bunchofkeys',
'serialkey.use.padlockfinder',
'serialkey.command.getkey',
]
}
'serialkey.craft.key' {
setDefault('TRUE')
description = 'Allows you to craft a key.'
}
'serialkey.craft.masterkey' {
setDefault('OP')
description = 'Allows you to craft a master key.'
}
'serialkey.craft.keyclone' {
setDefault('TRUE')
description = 'Allows you to clone a key.'
}
'serialkey.craft.bunchofkeys' {
setDefault('TRUE')
description = 'Allows you to bunch of keys.'
}
'serialkey.craft.padlockfinder' {
setDefault('TRUE')
description = 'Allows you to craft a padlock finder.'
}
'serialkey.use.key' {
setDefault('TRUE')
description = 'Allows you to use a key.'
}
'serialkey.use.masterkey' {
setDefault('OP')
description = 'Allows you to use a master key.'
}
'serialkey.use.bunchofkeys' {
setDefault('TRUE')
description = 'Allows you to use a bunch of keys.'
}
'serialkey.use.padlockfinder' {
setDefault('TRUE')
description = 'Allows you to use a padlock finder.'
}
'serialkey.command.getkey' {
setDefault('OP')
description = 'Allows you to use /serialkey getkey.'
}
}
}

repositories {
mavenCentral()
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'http://nexus.hc.to/content/repositories/pub_releases' }
maven { url = 'http://repo.bstats.org/content/repositories/releases/' }
}

dependencies {
implementation project(':core')
compileOnly 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT'
implementation 'org.bstats:bstats-bukkit-lite:1.2'
}

shadowJar {
destinationDir = new File(rootProject.projectDir, 'build/release/')
version = project.version
mergeServiceFiles()
relocate 'org.bstats.bukkit', 'fr.skyost.serialkey.bukkit.util.bstats'
}
@@ -0,0 +1,116 @@
package fr.skyost.serialkey.bukkit;

import fr.skyost.serialkey.core.object.PersonIdentity;
import fr.skyost.serialkey.core.object.SerialKeyLocation;
import fr.skyost.serialkey.core.object.SerialKeyPerson;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

/**
* A class that allows to convert core objects to Bukkit objects (and vice-versa).
*/

public class BukkitTypeConverter {

/**
* Converts a SerialKey location to a Bukkit location.
*
* @param location The SerialKey location.
*
* @return The Bukkit location.
*/

public static Location toBukkitLocation(final SerialKeyLocation location) {
return new Location(Bukkit.getWorld(location.getWorld()), location.getX(), location.getY(), location.getZ());
}

/**
* Converts a Bukkit location to a SerialKey location.
*
* @param location The Bukkit location.
*
* @return The SerialKey location.
*/

public static SerialKeyLocation toSerialKeyLocation(final Location location) {
return new SerialKeyLocation(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
}

/**
* Converts a SerialKey person to a Bukkit command sender.
*
* @param person The SerialKey person.
*
* @return The Bukkit command sender.
*/

public static CommandSender toBukkitPerson(final SerialKeyPerson person) {
final PersonIdentity identity = person.getIdentity();
if(identity.getType() == PersonIdentity.Type.CONSOLE) {
return Bukkit.getConsoleSender();
}

return Bukkit.getPlayer(identity.getName());
}

/**
* Converts a Bukkit command sender to a SerialKey person.
*
* @param sender Bukkit command sender.
*
* @return The SerialKey person.
*/

public static SerialKeyPerson toSerialKeyPerson(final CommandSender sender) {
return new BukkitPerson(sender);
}

/**
* Represents a Bukkit person.
*/

private static class BukkitPerson implements SerialKeyPerson {

/**
* The sender instance.
*/

private final CommandSender sender;

/**
* The identity.
*/

private final PersonIdentity identity;

/**
* Creates a new Bukkit person instance.
*
* @param sender The sender instance.
*/

BukkitPerson(final CommandSender sender) {
this.sender = sender;
this.identity = new PersonIdentity(sender instanceof Player ? PersonIdentity.Type.PLAYER : PersonIdentity.Type.CONSOLE, sender.getName());
}

@Override
public PersonIdentity getIdentity() {
return identity;
}

@Override
public void sendMessage(final String message) {
sender.sendMessage(message);
}

@Override
public boolean hasPermission(final String permission) {
return sender.hasPermission(permission);
}

}

}

0 comments on commit 1f617c1

Please sign in to comment.