Skip to content

Commit

Permalink
Merge pull request #8 from jeremynoesen/1.3.2
Browse files Browse the repository at this point in the history
1.3.2
  • Loading branch information
jeremynoesen authored Jan 7, 2021
2 parents bc321df + 55e13ea commit 735d20f
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 179 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ out/
*.zip
*.tar.gz
*.rar
hs_err_pid*
hs_err_pid*
gradlew.bat
gradlew
gradle
.gradle
build
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CourierNew is a built-from-scratch partial remake of an abandoned Bukkit plugin
- `couriernew.reload` - Allows for reloading of configs

## Requirements
- Spigot 1.13 - 1.16
- Spigot 1.13.0 - 1.16.4
- Java 8

## Installation
Expand Down Expand Up @@ -65,6 +65,9 @@ The third configuration file is actually used to store outgoing mail. Don't modi
## Demonstration
![Demonstration](demo.gif)

## Building
If you wish to build from source, a `build.gradle` is included to create the jar, as well as get dependencies if you import the project into your IDE.

## Troubleshooting
Courier not spawning?
- In the WorldGuard config, set `block-plugin-spawning` to false.
Expand Down
19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java'
}

group 'jeremynoesen.couriernew'
version '1.3.2'
compileJava.options.encoding = 'UTF-8'

repositories {
mavenCentral()
jcenter()
mavenLocal()
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
}

dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT'
}
150 changes: 0 additions & 150 deletions src/jeremynoesen/couriernew/CommandExec.java

This file was deleted.

133 changes: 133 additions & 0 deletions src/main/java/jeremynoesen/couriernew/CommandExec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package jeremynoesen.couriernew;

import jeremynoesen.couriernew.courier.Courier;
import jeremynoesen.couriernew.courier.CourierOptions;
import jeremynoesen.couriernew.letter.LetterChecker;
import jeremynoesen.couriernew.letter.LetterCreation;
import jeremynoesen.couriernew.letter.LetterSender;
import jeremynoesen.couriernew.letter.Outgoing;
import org.bukkit.GameMode;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.Set;

/**
* Command class, runs commands if not in blocked worlds or gamemodes.
*
* @author Jeremy Noesen
*/
public class CommandExec implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {

Player player = (Player) sender;
Set<GameMode> modes = CourierOptions.BLOCKED_GAMEMODES;
Set<World> worlds = CourierOptions.BLOCKED_WORLDS;

if (!worlds.contains(player.getWorld()) && !modes.contains(player.getGameMode())) {

switch (label.toLowerCase()) {

case "letter":
if (player.hasPermission("couriernew.letter")) {
if (args.length >= 1) {
StringBuilder sb = new StringBuilder();
for (String arg : args) {
sb.append(arg).append(" ");
}
if (LetterChecker.isHoldingOwnLetter(player) &&
!LetterChecker.wasSent(player.getInventory().getItemInMainHand()))
LetterCreation.editBook(player, sb.toString());
else LetterCreation.writeBook(player, sb.toString());
//lc.writeMap(player, sb.toString());
} else
player.sendMessage(Message.ERROR_NO_MSG);
} else
player.sendMessage(Message.ERROR_NO_PERMS);
break;

case "cnreload":
if (player.hasPermission("couriernew.reload")) {
Outgoing.saveAll();
Courier.getCouriers().keySet().forEach(Entity::remove);
Courier.getCouriers().clear();
Config.getMainConfig().reloadConfig();
Config.getOutgoingConfig().reloadConfig();
Config.getMessageConfig().reloadConfig();
CourierOptions.load();
Outgoing.loadAll();
Message.reloadMessages();
player.sendMessage(Message.SUCCESS_RELOADED);
} else
player.sendMessage(Message.ERROR_NO_PERMS);
break;

case "post":
if (args.length == 1) {
if (player.hasPermission("couriernew.post.one") || player.hasPermission("couriernew" +
".post.multiple") ||
player.hasPermission("couriernew.post.allonline") || player.hasPermission("couriernew" +
".post.all")) {
LetterSender.send(player, args[0]);
} else
player.sendMessage(Message.ERROR_NO_PERMS);
} else
player.sendMessage(Message.ERROR_TOO_MANY_ARGS);
break;

case "cnhelp":
if (player.hasPermission("couriernew.help")) {
player.sendMessage(Message.HELP);
} else
player.sendMessage(Message.ERROR_NO_PERMS);
break;

case "shred":
if (player.hasPermission("couriernew.shred")) {
LetterCreation.delete(player);
} else
player.sendMessage(Message.ERROR_NO_PERMS);
break;

case "shredall":
if (player.hasPermission("couriernew.shredall")) {
LetterCreation.deleteAll(player);
} else
player.sendMessage(Message.ERROR_NO_PERMS);
break;

case "unread":
if (player.hasPermission("couriernew.unread")) {
if (Outgoing.getOutgoing().containsKey(player) && Outgoing.getOutgoing().get(player).size() > 0) {
player.sendMessage(Message.SUCCESS_EXTRA_DELIVERIES);
new BukkitRunnable() {
@Override
public void run() {
if (player.isOnline()) {
LetterSender.spawnCourier(player);
}
}
}.runTaskLater(CourierNew.getInstance(), CourierOptions.RECEIVE_DELAY);
} else {
player.sendMessage(Message.ERROR_NO_MAIL);
}
} else
player.sendMessage(Message.ERROR_NO_PERMS);
break;
}
} else {
player.sendMessage(Message.ERROR_WORLD);
}
return true;
}
return false;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package jeremynoesen.couriernew.courier;

import com.earth2me.essentials.Essentials;
import de.myzelyam.supervanish.SuperVanish;
import jeremynoesen.couriernew.CourierNew;
import jeremynoesen.couriernew.Message;
import jeremynoesen.couriernew.letter.Outgoing;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.scheduler.BukkitRunnable;
import org.kitteh.vanish.VanishPlugin;

import java.util.HashMap;

Expand Down Expand Up @@ -167,26 +164,9 @@ public Entity getCourier() {
public static boolean canSpawn(Player recipient) {
if (!recipient.isOnline())
return false;

if (Bukkit.getPluginManager().isPluginEnabled("VanishNoPacket")) {
if (((VanishPlugin) Bukkit.getPluginManager().getPlugin("VanishNoPacket")).getManager().isVanished
(recipient)) {
recipient.sendMessage(Message.ERROR_VANISHED);
return false;
}
}

if (Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
if (((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"))
.getVanishedPlayers().contains(recipient.getName())) {
recipient.sendMessage(Message.ERROR_VANISHED);
return false;
}
}

if (Bukkit.getPluginManager().isPluginEnabled("SuperVanish")) {
if (((SuperVanish) Bukkit.getPluginManager().getPlugin("SuperVanish"))
.getVanishStateMgr().isVanished(recipient.getUniqueId())) {

for (MetadataValue meta : recipient.getMetadata("vanished")) {
if (meta.asBoolean()) {
recipient.sendMessage(Message.ERROR_VANISHED);
return false;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions resources/plugin.yml → src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: CourierNew
version: 1.3.1
description: A new form of Courier
version: 1.3.2
description: A unique mail system
author: Jeremaster101
main: jeremynoesen.couriernew.CourierNew
softdepend: [VanishNoPacket, Essentials, SuperVanish]
api-version: 1.13
commands:
letter:
Expand Down

0 comments on commit 735d20f

Please sign in to comment.