Skip to content

Commit

Permalink
v0.3 update
Browse files Browse the repository at this point in the history
Fixed a bunch of stuff, made prefix renamable in config.
  • Loading branch information
Xenoyia committed Apr 27, 2017
1 parent 9da9df9 commit 88ee105
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
connection.arguments=
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.java.home=null
connection.jvm.arguments=
connection.project.dir=
derived.resources=.gradle,build
eclipse.preferences.version=1
project.path=\:
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.xpgaming</groupId>
<artifactId>xPBottles</artifactId>
<version>0.2</version>
<version>0.3</version>
<name>xPBottles</name>
<repositories>
<repository>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/xpgaming/xPBottles/Bottle.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@
public class Bottle implements CommandExecutor {

public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
String prefix = Config.getInstance().getConfig().getNode("bottles", "prefix").getString();
if(src instanceof Player) {
Player player = (Player) src;
player.sendMessage(Text.of("§f[§bxP//§f] §b§l-- COMMANDS --"));
player.sendMessage(Text.of("§f[§b"+prefix+"§f] §b§l-- COMMANDS --"));
if(player.hasPermission("xpgaming.bottles.use")) {
player.sendMessage(Text.of(" §7> §b/bottle confirm §7- Convert your XP into bottles!"));
}
if(player.hasPermission("xpgaming.bottles.reload")) {
player.sendMessage(Text.of(" §7> §b/bottle reload §7- Reload plugin configuration!"));
}
} else {
src.sendMessage(Text.of("§f[§bxP//§f] §b§l-- COMMANDS --"));
src.sendMessage(Text.of("§f[§b"+prefix+"§f] §b§l-- COMMANDS --"));
src.sendMessage(Text.of(" §7> §b/bottle confirm §7- Convert your XP into bottles!"));
src.sendMessage(Text.of(" §7> §b/bottle reload §7- Reload plugin configuration!"));
}
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/xpgaming/xPBottles/BottleXP.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.xpgaming.xPBottles;

import java.net.URL;
import net.minecraft.server.MinecraftServer;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Optional;
Expand Down Expand Up @@ -40,6 +41,7 @@
public class BottleXP implements CommandExecutor {

public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
String prefix = Config.getInstance().getConfig().getNode("bottles", "prefix").getString();
if(src instanceof Player) {
Player player = (Player) src;
if(player.gameMode().get() == GameModes.SURVIVAL) {
Expand All @@ -50,20 +52,20 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
double bottlesNeeded = Math.ceil(totalEXP / 11);
createBottles(bottlesNeeded, player);
if(bottlesNeeded == 1) {
player.sendMessage(Text.of("§f[§axP//§f] §aSuccessfully exchanged your XP for §2" + (int)bottlesNeeded + "§a bottle!"));
} else player.sendMessage(Text.of("§f[§axP//§f] §aSuccessfully exchanged your XP for §2" + (int)bottlesNeeded + "§a bottles!"));
player.sendMessage(Text.of("§f[§a"+prefix+"§f] §aSuccessfully exchanged your XP for §2" + (int)bottlesNeeded + "§a bottle!"));
} else player.sendMessage(Text.of("§f[§a"+prefix+"§f] §aSuccessfully exchanged your XP for §2" + (int)bottlesNeeded + "§a bottles!"));
player.offer(Keys.TOTAL_EXPERIENCE, 0);
} else {
player.sendMessage(Text.of("§f[§cxP//§f] §cYou need at least " + minLevels + " levels to convert to bottles!"));
player.sendMessage(Text.of("§f[§c"+prefix+"§f] §cYou need at least " + minLevels + " levels to convert to bottles!"));
}
return CommandResult.success();
} else {
player.sendMessage(Text.of("§f[§cxP//§f] §cYou need to be in Survival mode to use this!"));
player.sendMessage(Text.of("§f[§c"+prefix+"§f] §cYou need to be in Survival mode to use this!"));
return CommandResult.success();
}
}
else {
src.sendMessage(Text.of("[xP//] You need to be a player to run this command!"));
src.sendMessage(Text.of("["+prefix+"] You need to be a player to run this command!"));
return CommandResult.success();
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/xpgaming/xPBottles/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public void configCreate() {
configFile.createNewFile();
configLoad();
CommentedConfigurationNode bottles = config.getNode("bottles").setComment("xP// Bottles coded by Xenoyia! Check out mc.xpgaming.com!");
bottles.getNode("min_level").setComment("Do not set this to lower than 2, it's hardcoded to not give half a bottle.").setValue("30");
bottles.getNode("min_level").setComment("Do not set this to lower than 2, it's hardcoded to not give half a bottle.").setValue("30");
bottles.getNode("prefix").setComment("[Prefix] goes before the messages, its default is 'Bottles'.").setValue("Bottles");
configSave();
} catch (IOException e) {
e.printStackTrace();
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/xpgaming/xPBottles/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.nio.file.Paths;
import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.config.ConfigDir;
Expand All @@ -21,8 +23,11 @@
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.loader.ConfigurationLoader;

@Plugin(id = "xpbottles", name = "xP// Bottles", version = "0.2")
@Plugin(id = Main.id, name = Main.name, version = "0.3")
public class Main {
public static final String id = "xpbottles";
public static final String name = "xP// Bottles";
private static final Logger log = LoggerFactory.getLogger(name);

CommandSpec confirm = CommandSpec.builder()
.description(Text.of("Bottle 30 levels of XP!"))
Expand Down Expand Up @@ -55,18 +60,14 @@ public class Main {
@Listener
public void onGameInitialization(GameInitializationEvent event) {
Config.getInstance().setup(configFile, configLoader);
log.info("Loaded v0.3!");
}

@Listener
public void onPreInitializationEvent(GameInitializationEvent event) {
Sponge.getCommandManager().register(this, bottle, "bottle", "xpbottle", "bottlexp", "xptobottle", "bxp");
}

@Listener
public void onServerStart(GameStartedServerEvent event) {
System.out.println("[xP// Bottles] Loaded v0.2!");
}


}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/xpgaming/xPBottles/Reload.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@
public class Reload implements CommandExecutor {
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
Config.getInstance().configLoad();
String prefix = Config.getInstance().getConfig().getNode("bottles", "prefix").getString();
if(src instanceof Player) {
Player player = (Player) src;
player.sendMessage(Text.of("§f[§bxP//§f] §bSuccessfully reloaded xP// Bottles!"));
player.sendMessage(Text.of("§f[§b"+prefix+"§f] §bSuccessfully reloaded xP// Bottles!"));
} else {
src.sendMessage(Text.of("§f[§bxP//§f] §bSuccessfully reloaded xP// Bottles!"));
src.sendMessage(Text.of("§f[§b"+prefix+"§f] §bSuccessfully reloaded xP// Bottles!"));
}
return CommandResult.success();
}
Expand Down

0 comments on commit 88ee105

Please sign in to comment.