This repository has been archived by the owner on Sep 18, 2022. It is now read-only.
forked from dvhaldane/BetterKits
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6edb150
commit 325f479
Showing
34 changed files
with
2,323 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,9 @@ | ||
*.class | ||
lib/ | ||
src/test/ | ||
.settings/ | ||
target/ | ||
.idea/ | ||
*.iml | ||
.classpath | ||
.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,15 @@ | ||
BetterKits | ||
Copyright (C) 2016 Antonino Kai Pocorobba | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
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,54 @@ | ||
###BetterKits | ||
BetterKits is a kit plugin compatible for Bukkit and Sponge. | ||
|
||
####Major features | ||
- Supports item NBT data (for modded items like bags!) | ||
- Supports Cauldron servers | ||
- Kit preview | ||
- Per kit cooldown (and per kit cooldown bypass permission ) | ||
- Per kit permission (users with this permission can get the kit without limits) | ||
- Command to give a limited amount of kits to players | ||
|
||
####Main commands | ||
- /kit (kitname) - get a kit | ||
- /kits - kit list | ||
- /kitcreate (kitname) - create a new kit for the target chest (just look at it directly) | ||
- /kitpreview (kitname) - shows a preview of the kit | ||
- /kitgive (player) (kitname) (amount) - gives the specified amount of the specified kit to the specified player | ||
|
||
####Links | ||
- [Latest release](https://github.com/KaiKikuchi/BetterKits/releases) | ||
- [Issue tracker](https://github.com/KaiKikuchi/BetterKits/issues) | ||
- [Source code](https://github.com/KaiKikuchi/BetterKits/) | ||
- [Personal page](http://mc.kaikk.net) | ||
- [Donate](http://mc.kaikk.net/#donate) | ||
|
||
####Basic installation and configuration | ||
- Copy the jar file under "/plugins/" (Bukkit) or "/mods/plugins/" (Sponge). | ||
- Restart the server. | ||
- Make a protected area in your server that will contain all the kit chests (e.g. a private dimension or another protected area). This area must be inaccessible to players. | ||
- Place a chest and fill it with the content of the kit you wish to create. | ||
- While looking at the chest within 4 blocks without any other block between you and the chest, use "/kitcreate (KitName)". | ||
- You can make more kits by placing a new chest and repeating the previous instructions. | ||
- WARNING: do not remove the chests you made for the kits! Those are used to read the kits items content! You also have to be sure they're are inaccesible to players, or they may steal from those chests! | ||
|
||
#####Further details | ||
Kits are stored into chests in the world so NBT data is preserved and kits can be modified easily. | ||
|
||
Kits can be created by placing a chest, filling the chest with items, then running the /kitcreate (kitname) command while looking at the chest. Do not remove the chests. Be sure to protect the chests from players. | ||
|
||
Players can get kits with the "/kit (kitname)" command. Kits can be added to players with the "/kitgive (playername) (kitname) (amount)", or allow them to get the kit without the amount limits with the permission node "betterkits.kit.(kitname)". | ||
|
||
Cooldown can be assigned to kits so the player won't spam the kit command with the command "/kitedit (kitname) cooldown (seconds)". Cooldown can be bypassed with the permission node "betterkits.cooldownbypass.kit.(kitname)". | ||
|
||
Players can preview the kits with the "/kitp (kitname)" command. The "betterkits.preview" permission node is necessary (default to true). | ||
|
||
Kit chest content is cached after first kit use. After modifying the kit chest content by either using the "/kitedit (kitname) content" or by manually opening the chest, use /kitclearcache. | ||
|
||
Commands can be also run when a player gets a kit. Check "/kitedit (kitname) <commandslist|addcommand|removecommand>". Commands are run by console. When adding a command, you can specify %name and %uuid and they'll be replaced with the player's name and uuid. | ||
|
||
Kits can be deleted with the "/kitdelete (kitname)" command. | ||
|
||
The config.yml/config.conf file contains a list of allowed chests. More chests can be added on the list by specifying the proper Material (Bukkit) or BlockType (Sponge) name. | ||
|
||
The plugin can be reloaded with /kitreload. |
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,78 @@ | ||
<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>net.kaikk.mc</groupId> | ||
<artifactId>BetterKits</artifactId> | ||
<version>0.9</version> | ||
<licenses> | ||
<license> | ||
<name>GPL v3 License</name> | ||
<url>http://www.gnu.org/licenses/</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
<issueManagement> | ||
<url>https://github.com/${developer}/${project.artifactId}/issues</url> | ||
<system>GitHub Issues</system> | ||
</issueManagement> | ||
<scm> | ||
<url>https://github.com/${developer}/${project.artifactId}</url> | ||
<connection>scm:git:git://github.com/${developer}/${project.artifactId}.git</connection> | ||
<developerConnection>scm:git:[email protected]:${developer}/${project.artifactId}.git</developerConnection> | ||
</scm> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.3.1</version> | ||
<configuration> | ||
<createChecksum>true</createChecksum> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
<repositories> | ||
<repository> | ||
<id>bukkit-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> | ||
</repository> | ||
<repository> | ||
<id>sponge</id> | ||
<url>http://repo.spongepowered.org/maven</url> | ||
</repository> | ||
</repositories> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.bukkit</groupId> | ||
<artifactId>bukkit</artifactId> | ||
<version>1.10.2-R0.1-SNAPSHOT</version> | ||
<type>jar</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.spongepowered</groupId> | ||
<artifactId>spongeapi</artifactId> | ||
<version>5.0.0-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
<properties> | ||
<package>net.kaikk.mc.betterkits</package> | ||
<developer>KaiNoMood</developer> | ||
</properties> | ||
</project> |
108 changes: 108 additions & 0 deletions
108
src/main/java/net/kaikk/mc/betterkits/bukkit/BetterKits.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,108 @@ | ||
package net.kaikk.mc.betterkits.bukkit; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.bukkit.configuration.serialization.ConfigurationSerialization; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
/* TODO | ||
* /kitinfo command? | ||
* preventing duplicate kits creation? | ||
* */ | ||
public class BetterKits extends JavaPlugin { | ||
private static BetterKits instance; | ||
private Config config; | ||
private Map<String, Kit> kits; | ||
private Map<UUID, PlayerData> playersData; | ||
|
||
@Override | ||
public void onEnable() { | ||
instance=this; | ||
|
||
ConfigurationSerialization.registerClass(Kit.class); | ||
ConfigurationSerialization.registerClass(PlayerData.class); | ||
|
||
config = new Config(instance); | ||
this.loadData(); | ||
Messages.load(this, "messages.yml"); | ||
|
||
this.getServer().getPluginManager().registerEvents(new EventListener(), this); | ||
|
||
// commands executor | ||
CommandExec ce = new CommandExec(this); | ||
this.getDescription().getCommands().keySet().forEach(cmd -> this.getCommand(cmd).setExecutor(ce)); | ||
} | ||
|
||
public static BetterKits instance() { | ||
return instance; | ||
} | ||
|
||
public Config config() { | ||
return config; | ||
} | ||
|
||
public Kit getKit(String name) { | ||
return this.kits.get(name.toLowerCase()); | ||
} | ||
|
||
public Kit addKit(Kit kit) { | ||
return this.kits.put(kit.getName().toLowerCase(), kit); | ||
} | ||
|
||
public Kit removeKit(String name) { | ||
return this.kits.remove(name.toLowerCase()); | ||
} | ||
|
||
public Collection<Kit> getKits() { | ||
return Collections.unmodifiableCollection(this.kits.values()); | ||
} | ||
|
||
public Map<UUID, PlayerData> getPlayersData() { | ||
return playersData; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
synchronized public void loadData() { | ||
FileConfiguration data = YamlConfiguration.loadConfiguration(new File(instance.getDataFolder(), "data.yml")); | ||
if (data==null) { | ||
instance.getLogger().severe("There was an error while loading data.yml!"); | ||
} else { | ||
List<Kit> kitsList = (List<Kit>) data.getList("Kits", Collections.emptyList()); | ||
this.kits = new HashMap<String, Kit>(); | ||
for (Kit kit : kitsList) { | ||
this.kits.put(kit.getName().toLowerCase(), kit); | ||
} | ||
|
||
List<PlayerData> playersDataList = (List<PlayerData>) data.getList("PlayersData", Collections.emptyList()); | ||
this.playersData = new HashMap<UUID, PlayerData>(); | ||
for (PlayerData pd : playersDataList) { | ||
this.playersData.put(pd.getPlayerUUID(), pd); | ||
} | ||
} | ||
} | ||
|
||
synchronized public void saveData() { | ||
File file = new File(this.getDataFolder(), "data.yml"); | ||
FileConfiguration data = YamlConfiguration.loadConfiguration(file); | ||
if (data==null) { | ||
this.getLogger().severe("There was an error while saving data.yml!"); | ||
} else { | ||
data.set("Kits", new ArrayList<Kit>(this.kits.values())); | ||
data.set("PlayersData", new ArrayList<PlayerData>(this.playersData.values())); | ||
try { | ||
data.save(file); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.