Skip to content

Commit

Permalink
Preparing for migration to API11
Browse files Browse the repository at this point in the history
  • Loading branch information
SawFowl committed Jul 1, 2024
1 parent fc589af commit cc720b5
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ public class PlaceholderKeys {

public static final String ITEM = "%item%";

public static final String AMOUNT = "%amount%";

public static final String SHOP = "%shop%";

public static final String REMOVED = "%removed%";

public static final String ADDED = "%added%";

public static final String BALANCE = "%balance%";

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package sawfowl.guishopmanager.configure.locale.abstractlocale;

import org.spongepowered.api.item.inventory.ItemStack;

public interface Debug {

String errorTakeMoney(String player);

String errorGiveMoney(String player);

String infoTakeMoney(String player, double removed, double balance);
String infoTakeMoney(ItemStack itemStack, String player, double removed, double balance);

String infoGiveMoney(String player, double added, double balance);
String infoGiveMoney(ItemStack itemStack, String player, double added, double balance);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public interface Gui {

interface Auction {

Component auction();

Component bet();

Component returnItems();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package sawfowl.guishopmanager.configure.locale.def;

import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;

import sawfowl.guishopmanager.configure.locale.PlaceholderKeys;
import sawfowl.guishopmanager.configure.locale.abstractlocale.Debug;

@ConfigSerializable
public class ImplementDebug implements Debug {

@Setting("ErrorTakeMoney")
private String errorTakeMoney = "Failed to remove money from balance of player %player%.";
@Setting("ErrorGiveMoney")
private String errorGiveMoney = "Failed to add money to the balance of player %player%.";
@Setting("InfoTakeMoney")
private String infoTakeMoney = "Item [%item%]%amount% removed from inventory of player %player%&a. Added money %removed%. Balance %balance%.";
@Setting("InfoGiveMoney")
private String infoGiveMoney = "Item [%item%]%amount% added to inventory of player %player%. Removed money %removed%. Balance %balance%.";
public ImplementDebug() {}

@Override
public String errorTakeMoney(String player) {
return errorTakeMoney.replace(PlaceholderKeys.PLAYER, player);
}

@Override
public String errorGiveMoney(String player) {
return errorGiveMoney.replace(PlaceholderKeys.PLAYER, player);
}

@Override
public String infoTakeMoney(ItemStack itemStack, String player, double removed, double balance) {
return infoTakeMoney.replace(PlaceholderKeys.ITEM, ItemTypes.registry().valueKey(itemStack.type()).asString()).replace(PlaceholderKeys.AMOUNT, String.valueOf(itemStack.quantity())).replace(PlaceholderKeys.PLAYER, player).replace(PlaceholderKeys.REMOVED, String.valueOf(removed)).replace(PlaceholderKeys.BALANCE, String.valueOf(balance));
}

@Override
public String infoGiveMoney(ItemStack itemStack, String player, double added, double balance) {
return infoGiveMoney.replace(PlaceholderKeys.ITEM, ItemTypes.registry().valueKey(itemStack.type()).asString()).replace(PlaceholderKeys.AMOUNT, String.valueOf(itemStack.quantity())).replace(PlaceholderKeys.PLAYER, player).replace(PlaceholderKeys.ADDED, String.valueOf(added)).replace(PlaceholderKeys.BALANCE, String.valueOf(balance));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package sawfowl.guishopmanager.configure.locale.def;

import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;

import sawfowl.guishopmanager.configure.locale.abstractlocale.Gui;
import sawfowl.guishopmanager.configure.locale.def.gui.*;

@ConfigSerializable
public class ImplementGui implements Gui {

@Setting("Auction")
private ImplementAuction auction = new ImplementAuction();
@Setting("Shop")
private ImplementShop shop = new ImplementShop();
@Setting("CommandShop")
private ImplementCommandShop commandShop = new ImplementCommandShop();
public ImplementGui() {}

@Override
public Auction auction() {
return auction;
}

@Override
public Shop shop() {
return shop;
}

@Override
public CommandShop commandShop() {
return commandShop;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package sawfowl.guishopmanager.configure.locale.def.gui;

import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;

import net.kyori.adventure.text.Component;

import sawfowl.guishopmanager.configure.locale.abstractlocale.Gui.Auction;
import sawfowl.localeapi.api.TextUtils;

@ConfigSerializable
public class ImplementAuction implements Auction {

@Setting("Auction")
private Component auction = TextUtils.deserializeLegacy("&2Auction");
@Setting("Bet")
private Component bet = TextUtils.deserializeLegacy("&2Bet");
@Setting("ReturnItems")
private Component returnItems = TextUtils.deserializeLegacy("&2Return items");
@Setting("Edit")
private Component edit = TextUtils.deserializeLegacy("&2Setting an item");
public ImplementAuction() {}

@Override
public Component auction() {
return auction;
}

@Override
public Component bet() {
return bet;
}

@Override
public Component returnItems() {
return returnItems;
}

@Override
public Component edit() {
return edit;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package sawfowl.guishopmanager.configure.locale.def.gui;

import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;

import net.kyori.adventure.text.Component;

import sawfowl.guishopmanager.configure.locale.abstractlocale.Gui.CommandShop;
import sawfowl.localeapi.api.TextUtils;

@ConfigSerializable
public class ImplementCommandShop implements CommandShop {

@Setting("Edit")
private Component edit = TextUtils.deserializeLegacy("&2Setting of purchase commands");
public ImplementCommandShop() {}

@Override
public Component edit() {
return edit;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package sawfowl.guishopmanager.configure.locale.def.gui;

import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;

import net.kyori.adventure.text.Component;

import sawfowl.guishopmanager.configure.locale.abstractlocale.Gui.Shop;
import sawfowl.localeapi.api.TextUtils;

@ConfigSerializable
public class ImplementShop implements Shop {

@Setting("EditBuy")
private Component editBuy = TextUtils.deserialize("&2Setting of purchase item");
@Setting("EditSell")
private Component editSell = TextUtils.deserialize("&2Setting of sell item");
@Setting("BuyTransaction")
private Component buyTransaction = TextUtils.deserialize("&2Buy");
@Setting("SellTransaction")
private Component sellTransaction = TextUtils.deserialize("&2Sell");
public ImplementShop() {}

@Override
public Component editBuy() {
return editBuy;
}

@Override
public Component editSell() {
return editSell;
}

@Override
public Component buyTransaction() {
return buyTransaction;
}

@Override
public Component sellTransaction() {
return sellTransaction;
}

}

0 comments on commit cc720b5

Please sign in to comment.