Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
0XPYEX0 committed Aug 22, 2022
1 parent 6431bbd commit e860ff8
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onDisable() {
}

public static FlyWithFoodBukkit getInstance() {
if (Util.checkNull(INSTANCE)) throw new IllegalStateException("插件尚未加载完成");
if (Util.checkNull(INSTANCE)) throw new IllegalStateException(FlyWithFood.PLUGIN_NOT_LOADED_MSG);

return INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class FlyWithFood {
private static FlyWithFood INSTANCE;
private static final String PLUGIN_NOT_LOADED_MSG = "插件尚未加载完成 || Plugin is invalid";
public static final String PLUGIN_NOT_LOADED_MSG = "插件尚未加载完成 || Plugin is invalid";
private final FlyWithFoodAPI API;

public FlyWithFood(FlyWithFoodAPI API) {
Expand Down Expand Up @@ -46,9 +46,19 @@ public void enable() {
getLogger().info(" ");

getAPI().registerEnergies();
getAPI().runTaskAsync(getAPI()::register_bStats);

FWFConfig.reload();
if (!FWFConfig.reload()) {
getLogger().severe("载入配置文件出错!插件加载已终止,请检查配置文件,如无法解决请查看后台报错并报告开发者. QQ:1723275529");
getLogger().severe("若确认是由配置文件错误导致加载出错,可在修改完毕后使用 /fly reload 重载以恢复");
getLogger().severe(" ");
getLogger().severe("ERROR!! The plugin loading has been terminated. Please check your config file.");
getLogger().severe("If you can not solve this problem, please check error messages in console and open a Issue to my GitHub.");
getLogger().severe("If you are sure that the config file has something wrong, you can use '/fly reload' after you fix that problem.");
getLogger().severe(" ");
return;
}

getAPI().runTaskAsync(getAPI()::register_bStats);

FlyWithFood.getInstance().getAPI().startCheck();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void onCmd(FWFSender sender, String label, String... args) {
sender.sendFWFMsg(FWFMsgType.NoPermission);
return;
}
if (FWFConfig.CONFIG.reload()) {
if (FWFConfig.reload()) {
if (FWFConfig.CONFIG.isChinese) {
sender.autoSendMsg("&a重载成功");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class FWFConfig {
public static File ROOT;
public static File CONFIG_FILE;
public static File BAK_FOLDER;
public static final int CONFIG_VERSION = 6;
public static final int CONFIG_VERSION = 5;
public static FWFConfig CONFIG;
public static final Gson GSON = new GsonBuilder()
.setPrettyPrinting()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package me.xpyex.plugin.flywithfood.common.implementation;

import java.util.Arrays;
import me.xpyex.plugin.flywithfood.common.FlyWithFood;
import me.xpyex.plugin.flywithfood.common.config.FWFConfig;
import me.xpyex.plugin.flywithfood.common.config.FWFInfo;
import me.xpyex.plugin.flywithfood.common.flyenergy.EnergyManager;
import me.xpyex.plugin.flywithfood.common.utils.GsonUtil;

public interface FWFUser extends FWFSender {
Expand All @@ -28,6 +30,11 @@ public default FWFInfo getInfo() {
break;
}
}
if (!EnergyManager.hasEnergy(mode)) {
FlyWithFood.getLogger().error("玩家 " + getName() + " 的CostMode错误!CostMode只应为 " + Arrays.toString(EnergyManager.getEnergies()) + " 中的一种. -> " + mode);
FlyWithFood.getLogger().error("ERROR!! CostMode does not exists! You can use these: " + Arrays.toString(EnergyManager.getEnergies()) + ". -> " + mode);
throw new IllegalStateException();
}
return new FWFInfo(cost, disable, mode);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package me.xpyex.plugin.flywithfood.sponge7;

import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import me.xpyex.plugin.flywithfood.common.FlyWithFood;
import me.xpyex.plugin.flywithfood.common.command.FWFCmdExecutor;
import me.xpyex.plugin.flywithfood.common.utils.Util;
import me.xpyex.plugin.flywithfood.sponge7.api.FlyWithFoodAPISponge7;
import me.xpyex.plugin.flywithfood.sponge7.bstats.Metrics;
import me.xpyex.plugin.flywithfood.sponge7.energies.SpongeMoney;
import me.xpyex.plugin.flywithfood.sponge7.implementation.SpongeSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -23,7 +22,6 @@
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.service.economy.EconomyService;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
Expand Down Expand Up @@ -59,40 +57,50 @@ public void onGameStart(GameStartedServerEvent event) {
Sponge.getCommandManager().register(INSTANCE, new CommandCallable() {
@Override
public @NotNull CommandResult process(@NotNull CommandSource source, @NotNull String arguments) throws CommandException {
System.out.println(arguments);
FWFCmdExecutor.onCmd(new SpongeSender(source), "fly", arguments);
String[] args;
if (arguments.trim().isEmpty()) {
args = new String[0];
} else {
args = arguments.split(" ");
}
FWFCmdExecutor.onCmd(new SpongeSender(source), "fly", args);
return CommandResult.success();
}

@Override
public @NotNull List<String> getSuggestions(@NotNull CommandSource source, @NotNull String arguments, @Nullable Location<World> targetPosition) throws CommandException {
return new ArrayList<>();
return Collections.emptyList();
//
}

@Override
public boolean testPermission(@NotNull CommandSource source) {
return true;
//
}

@Override
public @NotNull Optional<Text> getShortDescription(@NotNull CommandSource source) {
return Optional.of(Text.of("FlyWithFood的基础命令"));
//
}

@Override
public @NotNull Optional<Text> getHelp(@NotNull CommandSource source) {
return Optional.of(Text.of("这是可以帮助的吗"));
//
}

@Override
public @NotNull Text getUsage(@NotNull CommandSource source) {
return Text.of("没有Usage");
//
}
}, "flywithfood", "fly", "fwf");
}

public static FlyWithFoodSponge7 getInstance() {
if (Util.checkNull(INSTANCE)) throw new IllegalStateException("插件尚未加载完成");
if (Util.checkNull(INSTANCE)) throw new IllegalStateException(FlyWithFood.PLUGIN_NOT_LOADED_MSG);

return INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class FlyWithFoodAPISponge7 implements FlyWithFoodAPI {
private final FWFLogger logger;
private static final String SERVER_SOFTWARE = "Sponge-1.12";
private static final int SERVER_MAIN_VERSION = 12;
private static final Task.Builder SCHEDULER = Task.builder();

public FlyWithFoodAPISponge7() {
this.logger = new FWFLogger(new SpongeSender(Sponge.getServer().getConsole()));
Expand Down Expand Up @@ -120,7 +119,7 @@ public void stopTasks() {
}

public Task.Builder getScheduler() {
return SCHEDULER;
return Task.builder();
//
}

Expand Down

0 comments on commit e860ff8

Please sign in to comment.