Skip to content

Commit

Permalink
Merge pull request #28 from shantek/2.0.0-Dev
Browse files Browse the repository at this point in the history
V2.0 initial dev build
  • Loading branch information
shantek authored Sep 22, 2024
2 parents 6a7cc01 + 6139db0 commit a1cd9b3
Show file tree
Hide file tree
Showing 19 changed files with 1,375 additions and 493 deletions.
44 changes: 36 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,55 @@ Available now on [Modrinth](https://modrinth.com/plugin/postoffice), [CurgeForge
## How does the plugin work?

- Upload the JAR to your server and reboot
- Rename barrels in an anvil to "pobox" - if you want to use a different name, be sure to change this in the config and use /postoffice reload to update your config file.
- Make any desired changes to the config file (not essential), and then type /postoffice reload' as an op.
- Place your barrels in your amazing Post Office build.
- Place a sign on the front of the barrel and type the barrel owners name on the second line, this then becomes the owner of the post box.
- Place a blank sign on the front of the barrel.
- While looking at the sign, type '/postoffice register' to register the barrel in the config file.
- Again while looking at the sign, if permitted your players can type '/postoffice claim' on a registered post box to claim it.
- Admin/mods can look at a sign and use '/postoffice claim playername' to claim a post box on behalf of another player.
- Enjoy your awesome post office on your SMP!

![Plugin Usage Stats](https://bstats.org/signatures/bukkit/Post%20Office.svg)

## Commands
Below are the commands used to manage the post office barrels and plugin:

### /postoffice register
Place a barrel and a sign on the front. Run this command while looking at the sign to register the post box in the config.

### /postoffice claim
If players have the claim permission, this command will allow them to claim an already registered post box.

### /postoffice claim playername
Used for an admin/mod to claim a post box on behalf of another player.

### /postoffice remove
Run while looking at a registered or claimed post box to remove the owner and the post box from the config.

### /postoffice info
Run while looking at a post box barrel to get information about the registration state/owner.


## Permissions
The below permissions are intended for giving your mods extra access and abilities within your post office. By default, players will be able to access their own post box without any additional permission nodes being granted.

### shantek.postoffice.use
This permission prevents a player from using/interacting with the post office. All players have this by default, so use this to deny access to any players you wish to ban from the post box system.

### shantek.postoffice.removeitems
Allow these players to remove items from any post box
Allow these players to remove items from any post box.

### shantek.postoffice.register
Allow a player to register/remove a post box in the config.

### shantek.postoffice.create
Allow a player to create a post box
### shantek.postoffice.claim
Allow a player to claim their own post box.

### shantek.postoffice.break
Allow a player to break any post box
### shantek.postoffice.claim.others
Allow a player to claim a post box for other players (generally used by admin/mods).

### shantek.postoffice.updatenotification
Any player with this permission will be notified if there is an update to the plugin
Any player with this permission will be notified if there is an update to the plugin.

## External Links

Expand Down
49 changes: 13 additions & 36 deletions src/main/java/io/shantek/PostOffice.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package io.shantek;

import io.shantek.functions.*;
import io.shantek.listeners.*;

import java.io.File;
import java.io.IOException;
import java.util.logging.*;
import java.util.stream.Collectors;

import io.shantek.functions.*;
import io.shantek.listeners.*;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.nio.file.*;
import java.util.*;
Expand All @@ -28,9 +23,7 @@ public final class PostOffice extends JavaPlugin {
public Helpers helpers;
public BarrelProtection barrelProtection;
public TabCompleter tabCompleter;

public static PostOffice instance;

public String customBarrelName = "pobox";
public File mailFile;
public int previousItemCount = 0;
Expand All @@ -40,6 +33,7 @@ public final class PostOffice extends JavaPlugin {
public boolean postBoxProtection = true;
public boolean consoleLogs = true;
public boolean gotMailDelay = true;
public boolean signNotification = true;

public void onEnable() {

Expand All @@ -50,22 +44,20 @@ public void onEnable() {
helpers = new Helpers(this);
TabCompleter tabCompleter = new TabCompleter(this);

getCommand("postoffice").setTabCompleter(new TabCompleter(this));
Objects.requireNonNull(getCommand("postoffice")).setTabCompleter(new TabCompleter(this));

// Check for a data folder, create it if needed
helpers.checkForDataFolder();

this.mailFile = new File(getDataFolder(), "mail.txt");
this.mailFile = new File(getDataFolder(), "hasmail.txt");

getCommand("postoffice").setExecutor(new Commands(this));
Objects.requireNonNull(getCommand("postoffice")).setExecutor(new Commands(this));

// Create an instance of UpdateChecker
this.updateChecker = new UpdateChecker();

// Create an instance of PluginConfig
this.pluginConfig = new PluginConfig(this);

registerPluginPermissions();
pluginConfig.reloadConfigFile();

if (this.mailFile.exists()) {
Expand Down Expand Up @@ -112,32 +104,17 @@ public static PostOffice getInstance() {
if (instance == null) {
instance = new PostOffice();
}

return instance;
}

public void printInfoMessage(String message) {
getLogger().info(message); // Print to the console
@Override
public void onDisable() {
// Save the cache to file when the plugin is disabled
helpers.saveCacheToFile();
}

private void registerPluginPermissions() {
// Register the permission node
Permission removeItemsPermission = new Permission("shantek.postoffice.removeitems");
PluginManager pm = getServer().getPluginManager();
pm.addPermission(removeItemsPermission);

// Permission for breaking Post Boxes
Permission breakPermission = new Permission("shantek.postoffice.break");
pm.addPermission(breakPermission);

// Permission for creating Post Boxes
Permission createBoxPermission = new Permission("shantek.postoffice.create");
pm.addPermission(createBoxPermission);

// Permission for breaking Post Boxes
Permission updateNotificationPermission = new Permission("shantek.postoffice.updatenotification");
pm.addPermission(updateNotificationPermission);
public void printInfoMessage(String message) {
getLogger().info(message); // Print to the console
}


}
27 changes: 27 additions & 0 deletions src/main/java/io/shantek/functions/BarrelData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.shantek.functions;

import java.util.UUID;

public class BarrelData {
private final UUID ownerUUID;
private final String signLocation;
private final String state;

public BarrelData(UUID ownerUUID, String signLocation, String state) {
this.ownerUUID = ownerUUID;
this.signLocation = signLocation;
this.state = state;
}

public UUID getOwnerUUID() {
return ownerUUID;
}

public String getSignLocation() {
return signLocation;
}

public String getState() {
return state;
}
}
Loading

0 comments on commit a1cd9b3

Please sign in to comment.