Skip to content

Commit

Permalink
Vecrsion 3.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanBrouwer committed Mar 30, 2019
1 parent a9fd02a commit 35537cd
Show file tree
Hide file tree
Showing 24 changed files with 73 additions and 60 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
//Project details
description "All you need to set up a server and more!"
group "bammerbom"
version "3.0.12"
version "3.0.13"

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down Expand Up @@ -58,14 +58,14 @@ repositories {

dependencies {
//Don't shadow
compile "org.spongepowered:spongeapi:7.1.0-SNAPSHOT"
compile "org.spongepowered:spongeapi:8.0.0-SNAPSHOT"
compile "com.vexsoftware:nuvotifier-universal:2.3.4"
compile "io.github.nucleuspowered:Nucleus:0.25.0-S6.0"
compile 'net.minecrell:statusprotocol:0.3'

//Shadow
compile "com.goebl:david-webb:1.3.0"
compile 'org.bstats:bstats-sponge:1.1'
compile 'net.minecrell:statusprotocol:0.3'

//Geoip stuff
compile 'com.maxmind.geoip2:geoip2:2.8.1'
Expand All @@ -82,6 +82,7 @@ shadowJar {
dependencies {
include(dependency("com.goebl:david-webb:1.3.0"))
include(dependency('org.bstats:bstats-sponge:1.1'))
include(dependency('net.minecrell:statusprotocol:0.3'))

//Geoip stuff
include(dependency("com.maxmind.geoip2:geoip2:2.8.1"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public EnchantmentArgument(@Nullable Text key) {
@Override
public EnchantmentType parseValue(CommandSource sender, CommandArgs args) throws ArgumentParseException {
String value = args.next();
Optional<EnchantmentType> type = Sponge.getRegistry().getType(CatalogTypes.ENCHANTMENT, value);
Optional<EnchantmentType> type = Sponge.getRegistry().getType(CatalogTypes.ENCHANTMENT_TYPE, value);
if (!type.isPresent()) {
throw args.createError(Messages.getFormatted(sender, "item.command.itemenchant.notfound", "%enchantment%", value));
}
Expand All @@ -58,6 +58,6 @@ public EnchantmentType parseValue(CommandSource sender, CommandArgs args) throws

@Override
public List<String> complete(CommandSource src, CommandArgs args, CommandContext context) {
return Sponge.getRegistry().getAllOf(CatalogTypes.ENCHANTMENT).stream().map(CatalogType::getId).collect(Collectors.toList());
return Sponge.getRegistry().getAllOf(CatalogTypes.ENCHANTMENT_TYPE).stream().map(CatalogType::getId).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class TextSimplifier {
public static Text simplify(Text text) {
if (!hasContent(text)) {
return Text.EMPTY;
return Text.empty();
}
if (text.getChildren().isEmpty()) {
return text;
Expand Down Expand Up @@ -86,7 +86,7 @@ private static boolean hasContent(final Text text) {

public static Text simplyfyChildren(final Text parent, final Text child) {
if (!hasContent(child)) {
return Text.EMPTY;
return Text.empty();
}
// Obtain unformated builder
Text.Builder builder;
Expand Down Expand Up @@ -137,7 +137,7 @@ private static Stream<Text> streamChildren(final Text parent) {
}

private static boolean hasStyle(final Text text) {
return text.getFormat() != TextFormat.NONE || text.getHoverAction().isPresent() || text.getClickAction().isPresent() || text.getShiftClickAction().isPresent();
return text.getFormat() != TextFormat.of() || text.getHoverAction().isPresent() || text.getClickAction().isPresent() || text.getShiftClickAction().isPresent();
}

private static Text withoutChildren(final Text text) {
Expand Down Expand Up @@ -196,14 +196,14 @@ private static LiteralText forceMerge(final LiteralText first, final LiteralText

private static class Merger implements UnaryOperator<Text> {

private Text last = Text.EMPTY;
private Text last = Text.empty();

@Override
public Text apply(final Text text) {
final Optional<Text> merged = merge(this.last, text);
if (merged.isPresent()) {
this.last = merged.get();
return Text.EMPTY;
return Text.empty();
} else {
final Text temp = this.last;
this.last = text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public static List<LiteralText> getFormattedChars(Text text) {
//Get all chars
for (Text child : children) {
for (char c : getContent(child).toCharArray()) {
LiteralText.Builder builder = LiteralText.builder(c).format(child.getFormat()).onClick(child.getClickAction().orElse(null)).onHover(child.getHoverAction().orElse(null)).onShiftClick(child.getShiftClickAction().orElse(null));
LiteralText.Builder builder =
LiteralText.builder().append(Text.of(c)).format(child.getFormat()).onClick(child.getClickAction().orElse(null)).onHover(child.getHoverAction().orElse(null)).onShiftClick(child.getShiftClickAction().orElse(null));
chars.add(builder.build());
}
}
Expand All @@ -168,7 +169,7 @@ public static LiteralText subtext(Text text, int start, int end) {
}
List<LiteralText> chars = getFormattedChars(text);
//Get the chars needed
LiteralText.Builder sub = LiteralText.builder("");
LiteralText.Builder sub = LiteralText.builder();
for (Text tex : Arrays.copyOfRange(chars.toArray(new Text[chars.size()]), start, end)) {
sub.append(tex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void save(UltimateUser user, Boolean data) {
} else {
//Player is no longer afk
if (user.getPlayer().isPresent()) {
user.getPlayer().get().sendTitle(Title.builder().clear().title(Text.EMPTY).subtitle(Text.EMPTY).build());
user.getPlayer().get().sendTitle(Title.builder().clear().title(Text.empty()).subtitle(Text.empty()).build());
}
//Make sure the player is not afked instantly
AfkDetectionListener.afktime.put(user.getIdentifier(), System.currentTimeMillis());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onPickup(ChangeInventoryEvent.Pickup event, @First Player p) {
ModuleConfig config = Modules.BLACKLIST.get().getConfig().get();
CommentedConfigurationNode hnode = config.get();
for(SlotTransaction trans : event.getTransactions()){
ItemStack item = trans.getSlot().peek().get();
ItemStack item = trans.getSlot().peek();
CommentedConfigurationNode node = hnode.getNode("items", item.getType().getId());
if (!node.isVirtual()) {
if (node.getNode("deny-drop").getBoolean()) {
Expand All @@ -78,9 +78,8 @@ public void onChange(ChangeInventoryEvent event, @First Player p) {
CommentedConfigurationNode hnode = config.get();
try {
for (Inventory s : event.getTargetInventory().slots()) {
ItemStack item = s.peek().orElse(null);
if (item == null) continue;
CommentedConfigurationNode node = hnode.getNode("items", item.getItem().getId());
ItemStack item = s.peek();
CommentedConfigurationNode node = hnode.getNode("items", item.getType().getKey());
if (!node.isVirtual()) {
if (node.getNode("deny-possession").getBoolean()) {
s.poll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package bammerbom.ultimatecore.sponge.modules.blockprotection.api.locktype;

import org.spongepowered.api.CatalogKey;
import org.spongepowered.api.registry.CatalogRegistryModule;

import java.util.*;
Expand All @@ -41,8 +42,8 @@ public void registerDefaults() {
}

@Override
public Optional<LockType> getById(String id) {
return Optional.ofNullable(this.mapping.get(checkNotNull(id).toLowerCase(Locale.ENGLISH)));
public Optional<LockType> get(CatalogKey key) {
return Optional.ofNullable(this.mapping.get(checkNotNull(key).getValue().toLowerCase(Locale.ENGLISH)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
package bammerbom.ultimatecore.sponge.modules.blockprotection.api.locktype;

import bammerbom.ultimatecore.sponge.UltimateCore;
import org.spongepowered.api.CatalogKey;

public class PasswordLockType implements ValueLockType {
private String password;

Expand All @@ -31,8 +34,8 @@ public PasswordLockType(String password) {
}

@Override
public String getId() {
return "password";
public CatalogKey getKey() {
return CatalogKey.builder().namespace(UltimateCore.get()).value("password").build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
*/
package bammerbom.ultimatecore.sponge.modules.blockprotection.api.locktype;

import bammerbom.ultimatecore.sponge.UltimateCore;
import org.spongepowered.api.CatalogKey;

public class PrivateLockType implements LockType {

@Override
public String getId() {
return "private";
public CatalogKey getKey() {
return CatalogKey.builder().namespace(UltimateCore.get()).value("private").build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@
*/
package bammerbom.ultimatecore.sponge.modules.blockprotection.api.locktype;

import bammerbom.ultimatecore.sponge.UltimateCore;
import org.spongepowered.api.CatalogKey;

public class PublicLockType implements LockType {
@Override
public String getId() {
return "public";
}

@Override
public CatalogKey getKey() {
return CatalogKey.builder().namespace(UltimateCore.get()).value("public").build();
}

@Override
public String getName() {
return "Public";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.entity.DestructEntityEvent;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.TranslatableText;
Expand Down Expand Up @@ -66,7 +65,7 @@ public void onDeath(DestructEntityEvent event) {
String id_uc = id_mc.toLowerCase().replaceFirst("death\\.", "deathmessage.message.");

//Item
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).orElse(ItemStack.of(ItemTypes.NONE, 1));
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);
Text item = stack.get(Keys.DISPLAY_NAME).orElse(Text.of(stack.getTranslation().get()));

//Final message //TODO hover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@
import org.spongepowered.api.command.args.CommandElement;
import org.spongepowered.api.data.type.HandTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.text.Text;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@CommandInfo(module = ItemModule.class, aliases = {"hat"})
@CommandPermissions(level = PermissionLevel.VIP)
Expand All @@ -68,18 +66,18 @@ public Map<String, PermissionInfo> registerPermissionSuffixes() {
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
checkIfPlayer(sender);
Player p = (Player) sender;
ItemStack hand = p.getItemInHand(HandTypes.MAIN_HAND).orElse(ItemStack.builder().itemType(ItemTypes.NONE).build());
ItemStack hand = p.getItemInHand(HandTypes.MAIN_HAND);
if (!args.hasAny("player")) {
Optional<ItemStack> headOp = p.getHelmet();
ItemStack headOp = p.getHelmet();
p.setHelmet(hand);
p.setItemInHand(HandTypes.MAIN_HAND, headOp.orElse(null));
p.setItemInHand(HandTypes.MAIN_HAND, headOp);
Messages.send(sender, "item.command.hat.self");
} else {
checkPermSuffix(sender, "others");
Player t = args.<Player>getOne("player").get();
Optional<ItemStack> headOp = t.getHelmet();
ItemStack headOp = t.getHelmet();
t.setHelmet(hand);
headOp.ifPresent(head -> t.getInventory().offer(head));
t.getInventory().offer(hand);
p.setItemInHand(HandTypes.MAIN_HAND, null);
Messages.send(sender, "item.command.hat.others.self", "%player%", t);
Messages.send(t, "item.command.hat.others.others", "%player%", t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
checkPermission(sender, ItemPermissions.UC_ITEM_ITEMCANBREAK_BASE);
Player p = (Player) sender;

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);
Set<BlockType> types = new HashSet<>(args.<BlockType>getAll("blocktypes"));

stack.offer(Keys.BREAKABLE_BLOCK_TYPES, types);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
checkPermission(sender, ItemPermissions.UC_ITEM_ITEMCANPLACEON_BASE);
Player p = (Player) sender;

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);
Set<BlockType> types = new HashSet<>(args.<BlockType>getAll("blocktypes"));

stack.offer(Keys.PLACEABLE_BLOCKS, types);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
checkPermission(sender, ItemPermissions.UC_ITEM_ITEMDURABILITY_BASE);
Player p = (Player) sender;

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);
int durability = args.<Integer>getOne("durability").get();

if (!stack.supports(DurabilityData.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
checkPermission(sender, ItemPermissions.UC_ITEM_ITEMENCHANT_BASE);
Player p = (Player) sender;

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);

EnchantmentType ench = args.<EnchantmentType>getOne("enchantment").get();
int level = args.hasAny("level") ? args.<Integer>getOne("level").get() : 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
checkPermission(sender, ItemPermissions.UC_ITEM_ITEMHIDETAGS_BASE);
Player p = (Player) sender;

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);

Key<Value<Boolean>> key = args.<Key<Value<Boolean>>>getOne("tag").get();
boolean value = args.<Boolean>getOne("enabled").get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
checkPermission(sender, ItemPermissions.UC_ITEM_ITEMLORE_BASE);
Player p = (Player) sender;

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);

Text unsplitlore = Messages.toText(args.<String>getOne("lore").get());
stack.offer(Keys.ITEM_LORE, unsplitlore.toPlain().contains("|") ? TextUtil.split(unsplitlore, "|") : Arrays.asList(unsplitlore));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
checkPermission(sender, ItemPermissions.UC_ITEM_ITEMNAME_BASE);
Player p = (Player) sender;

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);

Text name = Messages.toText(args.<String>getOne("name").get());
stack.offer(Keys.DISPLAY_NAME, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C
checkPermission(sender, ItemPermissions.UC_ITEM_ITEMDURABILITY_BASE);
Player p = (Player) sender;

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);
int quantity = args.<Integer>getOne("quantity").get();

if (quantity > stack.getMaxStackQuantity()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public CommandResult execute(CommandSource sender, CommandContext args) throws C

Boolean value = args.<Boolean>getOne("enabled/disabled").get();

if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) {
throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
}
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();
ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND);

if (!stack.supports(Keys.UNBREAKABLE)) {
throw new ErrorMessageException(Messages.getFormatted(sender, "item.command.itemunbreakable.notsupported"));
Expand Down
Loading

0 comments on commit 35537cd

Please sign in to comment.