-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from jeremynoesen/1.3.2
1.3.2
- Loading branch information
Showing
18 changed files
with
168 additions
and
179 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 |
---|---|---|
|
@@ -12,4 +12,9 @@ out/ | |
*.zip | ||
*.tar.gz | ||
*.rar | ||
hs_err_pid* | ||
hs_err_pid* | ||
gradlew.bat | ||
gradlew | ||
gradle | ||
.gradle | ||
build |
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
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,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' | ||
} |
This file was deleted.
Oops, something went wrong.
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,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.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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