Skip to content

Commit

Permalink
0.9.0 - GDP command, admin commands and other improvements
Browse files Browse the repository at this point in the history
Features:
+ Added /gdp to view GDP and per capita GDP
+ Added /increase and /decrease to easily increase and decrease the prices of items
+ Improved player UI and feedback
+ Added server name to more areas of the plugin
+ Improved data search algorithim for temporary data
Fixes:
+ Fixed a lot of plugin incompatiblity issues
+ Fixed intrest rate being too high on startup
+ Improved code quality
+ Removed unneeded lines and comments
+ Fixed autotune not apperaing in some log messages
+ Fixed random debug messages
+ Fixed /at command frequently throwing an error
+ Fixed some commands throwing usage info when used correctly
Other
+ Some grammatical improvements
+ More info and coherent README.MD
+ Updated to 0.9.0
  • Loading branch information
noahbclarkson committed Sep 8, 2020
1 parent cd4cd66 commit e79df89
Show file tree
Hide file tree
Showing 23 changed files with 265 additions and 105 deletions.
Binary file modified .github/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion Auto-Tune/.project
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
<filteredResources>
<filter>
<id>1599074862940</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
2 changes: 1 addition & 1 deletion Auto-Tune/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>unprotesting.com.github</groupId>
<artifactId>Auto-Tune</artifactId>
<name>Auto-Tune</name>
<version>0.8.5</version>
<version>0.9.0</version>
<description>The automatic pricing plugin for minecraft</description>
<url>https://github.com/Unprotesting/Auto-Tune</url>
<issueManagement>
Expand Down
2 changes: 1 addition & 1 deletion Auto-Tune/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Project information -->
<groupId>unprotesting.com.github</groupId>
<artifactId>Auto-Tune</artifactId>
<version>0.8.5</version>
<version>0.9.0</version>
<packaging>jar</packaging>
<!-- Info -->
<name>Auto-Tune</name>
Expand Down
6 changes: 3 additions & 3 deletions Auto-Tune/src/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ email: '[email protected]'
## Enable//Disable integrated Web Server.
web-server-enabled: true

## Port for integrated Web Server (If enabled and on correct plan)
## Port for integrated Web Server (If enabled)
port: 8123

## The maximum length in data points that the trade-short.html will show (this doesn't affect data)
Expand Down Expand Up @@ -90,7 +90,7 @@ currency-symbol: '$'
## Enable sell price difference variation to ease out sell price varition
sell-price-difference-variation-enabled: false
## Starting percententage sell price difference for sell price varition
sell-price-differnence-variation-start: 25.0
sell-price-difference-variation-start: 25.0
## Time in minutes until sell price reaches sell-price-difference set in pricing model settings (default 7 days)
sell-price-variation-time-period: 10080
## Time in minutes that the sell-price-difference updates
Expand All @@ -113,7 +113,7 @@ static-inflation-value: 0.1

## Intrest rate per intrest-rate-update-period
## Info: This is the increase in the current debt payment per-time period
intrest-rate: 0.01
intrest-rate: 0.001
## Time period in ticks between updates of the intrest rate for users loans
intrest-rate-update-period: 1200

Expand Down
12 changes: 11 additions & 1 deletion Auto-Tune/src/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ api-version: 1.16
commands:
at:
description: Auto-Tune Command.
usage: /<at> <login>
usage: /<at> <login|increase|decrease>
trade:
description: Trade Online with other players.
usage: /<trade>
Expand All @@ -40,9 +40,13 @@ commands:
payloan:
description: Payback one of your loans
usage: <payloan> <loanNo.>
gdp:
description: View GDP info
usage: <GDP>
permssions:
at.help:
description: Displays Auto-Tune help information
default: true
at.login:
description: Login to an Auto-Tune account |(active soon)|
at.shop:
Expand All @@ -53,6 +57,12 @@ permssions:
description: Open the Auto-Sell GUI and Auto-Sell
at.loan:
description: Loan money from the bank
at.increase:
description: Increase price of an item
at.decrease:
description: Decrease price of an item
at.gdp:
description: View GDP info



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,6 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) {
pane.addPane(1, SBPane);
}

// page two
// **if (size > menuRows*7){
// OutlinePane pageTwo = new OutlinePane(1, 1, 7, menuRows-2);
// pageTwo.addItem(new GuiItem(new ItemStack(Material.GLASS), event ->
// event.getWhoClicked().sendMessage("Glass")));
// pane.addPane(1, pageTwo);
// }

// page three
// if (size > menuRows*14){
// OutlinePane pageThree = new OutlinePane(1, 1, 7, menuRows-2);
// pageThree.addItem(new GuiItem(new ItemStack(Material.BLAZE_ROD),event ->
// event.getWhoClicked().sendMessage("Blaze rod")));
// pane.addPane(2, pageThree);
// }

gui1.addPane(pane);

// page selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

import net.md_5.bungee.api.ChatColor;
import unprotesting.com.github.Main;
import unprotesting.com.github.util.Config;
import unprotesting.com.github.util.InflationEventHandler;
import unprotesting.com.github.util.TextHandler;

public class AutoTuneCommand implements CommandExecutor {

static Logger log = Logger.getLogger("Minecraft");
public static Logger log = Logger.getLogger("Minecraft");

@Override
public boolean onCommand(CommandSender sender, Command command, String at, String[] args) {
Expand All @@ -30,32 +32,96 @@ public boolean onCommand(CommandSender sender, Command command, String at, Strin
Main.playerDataConfig.set(uuid + ".autotuneID", AutoTunePlayerID);
Main.saveplayerdata();
player.sendMessage(ChatColor.YELLOW + "Creating one for you..");
player.sendMessage(ChatColor.YELLOW + "Created Auto-Tune Account with Unique ID: " + AutoTunePlayerID);}
player.sendMessage(ChatColor.YELLOW + "Created Auto-Tune Account with Unique ID: " + AutoTunePlayerID);return true;}

else if (LoggedIn != null){
player.sendMessage(ChatColor.YELLOW + "Already Logged in!");
player.sendMessage(ChatColor.YELLOW + "Your unique ID is " + Main.playerDataConfig
.getString(uuid + ".autotuneID"));
return true;
}
}
else if (!(player.hasPermission("at.login")) && !(player.isOp())){
TextHandler.noPermssion(player);
return true;
}
}

else {
if (player.hasPermission("at.help") || player.isOp()){
player.sendMessage(ChatColor.YELLOW + "\"/at\" command usage:");
player.sendMessage(ChatColor.YELLOW + "/at login | Login to trading plaform");
player.sendMessage(ChatColor.YELLOW + "/at Register | Register to trading plaform");
player.sendMessage(ChatColor.YELLOW + "- /at login | Login to trading plaform");
player.sendMessage(ChatColor.YELLOW + "- /at Register | Register to trading plaform");
player.sendMessage(ChatColor.YELLOW + "- /at Increase <Item-Name> <Value | %Value> | Increase Item Price");
player.sendMessage(ChatColor.YELLOW + "- /at Decrease <Item-Name> <Value | %Value> | Decrease Item Price");
return true;
}
else if (!(player.hasPermission("at.help")) && !(player.isOp())){
TextHandler.noPermssion(player);
return true;
}
}
}

return true;

}
if (args[0].equalsIgnoreCase("increase")) {
if (player.hasPermission("at.increase") || player.isOp()){
Double value = Double.valueOf(args[2]);
if (!(value == 0 || value == 0.0 || value == 0f || value > 99999999 || args[1] == null || args[2] == null)){
if (args[1].contains("%")){
args[1].replace("%", "");
Double newPrice = InflationEventHandler.increaseItemPrice(args[1].toUpperCase(), value, true);
player.sendMessage(ChatColor.YELLOW + "Increased " + args[1].toUpperCase() + " price to " + ChatColor.GREEN + Config.getCurrencySymbol() + newPrice);
return true;
}
else {
Double newPrice = InflationEventHandler.increaseItemPrice(args[1].toUpperCase(), value, true);
player.sendMessage(ChatColor.YELLOW + "Increased " + args[1].toUpperCase() + " price to " + ChatColor.GREEN + Config.getCurrencySymbol() + newPrice);
return true;
}
}
}
else if (!(player.hasPermission("at.increase")) && !(player.isOp())){
TextHandler.noPermssion(player);
return true;
}
}
if (args[0].equalsIgnoreCase("decrease")) {
if (player.hasPermission("at.decrease") || player.isOp()){
Double value = Double.valueOf(args[2]);
if (!(value == 0 || value == 0.0 || value == 0f || value > 99999999 || args[1] == null || args[2] == null)){
if (args[1].contains("%")){
args[1].replace("%", "");
Double newPrice = InflationEventHandler.decreaseItemPrice(args[1].toUpperCase(), value, true);
player.sendMessage(ChatColor.YELLOW + "Decreased " + args[1].toUpperCase() + " price to " + ChatColor.GREEN + Config.getCurrencySymbol() + newPrice);
return true;
}
else {
Double newPrice = InflationEventHandler.decreaseItemPrice(args[1].toUpperCase(), value, true);
player.sendMessage(ChatColor.YELLOW + "Decreased " + args[1].toUpperCase() + " price to " + ChatColor.GREEN + Config.getCurrencySymbol() + newPrice);
return true;
}
}
}
else if (!(player.hasPermission("at.decrease")) && !(player.isOp())){
TextHandler.noPermssion(player);
return true;
}
}
else{
if (player.hasPermission("at.help") || player.isOp()){
player.sendMessage(ChatColor.YELLOW + "\"/at\" command usage:");
player.sendMessage(ChatColor.YELLOW + "- /at login | Login to trading plaform");
player.sendMessage(ChatColor.YELLOW + "- /at Register | Register to trading plaform");
player.sendMessage(ChatColor.YELLOW + "- /at Increase <Item-Name> <Value | %Value> | Increase Item Price");
player.sendMessage(ChatColor.YELLOW + "- /at Decrease <Item-Name> <Value | %Value> | Decrease Item Price");
return true;
}
else if (!(player.hasPermission("at.help")) && !(player.isOp())){
TextHandler.noPermssion(player);
return true;
}
}
}
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package unprotesting.com.github.Commands;

import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import net.md_5.bungee.api.ChatColor;
import unprotesting.com.github.Main;
import unprotesting.com.github.util.TextHandler;

public class AutoTuneGDPCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String gdp, String[] args) {
Player p = (Player) sender;
if (command.getName().equalsIgnoreCase("gdp")){
if (p.hasPermission("at.gdp") || p.isOp()){
String GDP = AutoTuneGUIShopUserCommand.df2.format(Main.tempdatadata.get("GDP"));
double returnedGDP = Double.parseDouble(GDP);
double[] serverBalance = getServerBalance();
double loanBalance = getLoanBalance();
returnedGDP += serverBalance[0];
returnedGDP -= loanBalance;
p.sendMessage(ChatColor.GOLD + "The Current GDP is: " + ChatColor.GREEN + AutoTuneGUIShopUserCommand.df2.format(returnedGDP));
p.sendMessage(ChatColor.GOLD + "The Current GDP per capita is: " + ChatColor.GREEN + AutoTuneGUIShopUserCommand.df2.format(returnedGDP/serverBalance[1]));
}
else if (!(p.hasPermission("at.gdp")) && !(p.isOp())){
TextHandler.noPermssion(p);
return true;
}
}
return true;
}

public double[] getServerBalance(){
double [] output = new double[2];
output[0] = 0.0;
output[1] = 0.0;
for (OfflinePlayer player : Bukkit.getOfflinePlayers()){
double x = Main.getEconomy().getBalance(player);
output[0] += x;
output[1] += 1;
}
return output;
}

public double getLoanBalance(){
double output = 0.0;
for (String str : Main.loanMap.keySet()){
double[] arr = Main.loanMap.get(str);
output += arr[0];
}
return output;
}

}
Loading

0 comments on commit e79df89

Please sign in to comment.