1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +01:00

Merge pull request #1400 from DekitateServer/dekitateserver/resetexploreregion

resetexploreregion command for reseting world region data for Exploring.
This commit is contained in:
Zrips 2022-03-07 14:29:24 +02:00 committed by GitHub
commit e8add46b46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 118 additions and 8 deletions

View File

@ -389,7 +389,7 @@ public final class Jobs extends JavaPlugin {
public static ExploreManager getExplore() { public static ExploreManager getExplore() {
if (exploreManager == null) if (exploreManager == null)
exploreManager = new ExploreManager(); exploreManager = ExploreManager.getInstane();
return exploreManager; return exploreManager;
} }

View File

@ -0,0 +1,36 @@
package com.gamingmesh.jobs.commands.list;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.config.ExploreManager;
import org.bukkit.command.CommandSender;
public class resetexploreregion implements Cmd {
private static String WORLD = "world";
private static String REGEX = "^[0-9a-zA-Z_-]+$";
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length != 2 || !WORLD.equals(args[0])) {
Jobs.getCommandManager().sendUsage(sender, "resetexploreregion");
return true;
}
if (!Jobs.getGCManager().resetExploringData) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.notenabled"));
return true;
}
final String worldName = args[1];
if(!worldName.matches(REGEX)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.invalidname"));
return true;
}
ExploreManager manager = ExploreManager.getInstane();
manager.resetRegion(worldName);
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.reseted", "%worldname%", worldName));
return true;
}
}

View File

@ -19,6 +19,17 @@ import com.gamingmesh.jobs.stuff.Util;
public class ExploreManager { public class ExploreManager {
private static ExploreManager instance;
public static ExploreManager getInstane() {
if(null == instance) {
instance = new ExploreManager();
}
return instance;
}
private ExploreManager() {
}
private final Map<String, Map<String, ExploreRegion>> worlds = new HashMap<>(); private final Map<String, Map<String, ExploreRegion>> worlds = new HashMap<>();
private boolean exploreEnabled = false; private boolean exploreEnabled = false;
private int playerAmount = 1; private int playerAmount = 1;
@ -139,4 +150,18 @@ public class ExploreManager {
} }
} }
public void resetRegion(String worldname) {
Jobs.consoleMsg("&eReseting explorer data. World: " + worldname);
Map<String, Map<String, ExploreRegion>> worlds = getWorlds();
worlds.put(worldname, new HashMap<String, ExploreRegion>());
boolean r = Jobs.getJobsDAO().deleteExploredWorld(worldname);
if(!r) {
Jobs.consoleMsg("&eFailed in DAO.");
return;
}
Jobs.consoleMsg("&eCompleted to reset explorer data.");
}
} }

View File

@ -89,7 +89,7 @@ public class GeneralConfigManager {
public boolean ignoreOreGenerators, useBlockProtection, enableSchedule, PayForRenaming, PayForEnchantingOnAnvil, PayForEachCraft, SignsEnabled, public boolean ignoreOreGenerators, useBlockProtection, enableSchedule, PayForRenaming, PayForEnchantingOnAnvil, PayForEachCraft, SignsEnabled,
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames, SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames,
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps, PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps,
BrowseUseNewLook, payExploringWhenGliding = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding, BrowseUseNewLook, payExploringWhenGliding = false, resetExploringData = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding,
boostedItemsInOffHand = false, boostedItemsInMainHand, boostedArmorItems/*, preventCropResizePayment*/, payItemDurabilityLoss, boostedItemsInOffHand = false, boostedItemsInMainHand, boostedArmorItems/*, preventCropResizePayment*/, payItemDurabilityLoss,
applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useMinimumOveralExp, useBreederFinder, applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useMinimumOveralExp, useBreederFinder,
CancelCowMilking, fixAtMaxLevel, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, CancelCowMilking, fixAtMaxLevel, TitleChangeChat, TitleChangeActionBar, LevelChangeChat,
@ -456,6 +456,9 @@ public class GeneralConfigManager {
payExploringWhenGliding = c.get("enable-pay-for-exploring-when-gliding", false); payExploringWhenGliding = c.get("enable-pay-for-exploring-when-gliding", false);
} }
c.addComment("enable-reset-exploring-data", "Option to allow reset exploring data.");
resetExploringData = c.get("enable-reset-exploring-data", false);
c.addComment("disablePaymentIfRiding", "Disables the payment when the player riding on an entity."); c.addComment("disablePaymentIfRiding", "Disables the payment when the player riding on an entity.");
disablePaymentIfRiding = c.get("disablePaymentIfRiding", false); disablePaymentIfRiding = c.get("disablePaymentIfRiding", false);

View File

@ -209,6 +209,13 @@ public class LanguageManager {
c.get("command.limit.output.reachedpointslimit2", "&eYou can check your limit with &2/jobs limit &ecommand"); c.get("command.limit.output.reachedpointslimit2", "&eYou can check your limit with &2/jobs limit &ecommand");
c.get("command.limit.output.notenabled", "&eMoney limit is not enabled"); c.get("command.limit.output.notenabled", "&eMoney limit is not enabled");
c.get("command.resetexploreregion.help.info", "Resets region data of Explorering");
c.get("command.resetexploreregion.help.args", "world [worldname]");
Jobs.getGCManager().getCommandArgs().put("resetlimit", Arrays.asList("world", "[worldname]"));
c.get("command.resetexploreregion.output.notenabled", "&eNot enabled.");
c.get("command.resetexploreregion.output.invalidname", "&eInvalid world name");
c.get("command.resetexploreregion.output.reseted", "&eExploring region data has been reset for: &2%worldname%");
c.get("command.resetlimit.help.info", "Resets a player's payment limits"); c.get("command.resetlimit.help.info", "Resets a player's payment limits");
c.get("command.resetlimit.help.args", "[playername]"); c.get("command.resetlimit.help.args", "[playername]");
Jobs.getGCManager().getCommandArgs().put("resetlimit", Arrays.asList("[playername]")); Jobs.getGCManager().getCommandArgs().put("resetlimit", Arrays.asList("[playername]"));

View File

@ -2613,6 +2613,37 @@ public abstract class JobsDAO {
} }
/**
* Delete player-explore information
* @param worldName - the world getting removed
*/
public boolean deleteExploredWorld(String worldName) {
if (!Jobs.getExplore().isExploreEnabled())
return false;
JobsConnection conn = getConnection();
if (conn == null)
return false;
JobsWorld target = Util.getJobsWorld(worldName);
if (null == target) {
return false;
}
PreparedStatement prest = null;
try {
prest = conn.prepareStatement("DELETE FROM `" + DBTables.ExploreDataTable.getTableName() + "` WHERE `" + ExploreDataTableFields.worldid.getCollumn() + "` = ?;");
prest.setInt(1, target.getId());
prest.execute();
} catch (Throwable e) {
e.printStackTrace();
return false;
} finally {
close(prest);
}
return true;
}
/** /**
* Save player-job information * Save player-job information
* @param jobInfo - the information getting saved * @param jobInfo - the information getting saved

View File

@ -151,6 +151,14 @@ command:
reachedpointslimit: '&4ポイント獲得上限に達しました' reachedpointslimit: '&4ポイント獲得上限に達しました'
reachedpointslimit2: '&2/jobs limit &eコマンドで上限を確認できます' reachedpointslimit2: '&2/jobs limit &eコマンドで上限を確認できます'
notenabled: '&e上限は有効化されていません' notenabled: '&e上限は有効化されていません'
resetexploreregion:
help:
info: '指定したワールドの探索情報をリセットします'
args: 'world [worldname]'
output:
notenabled: '機能が無効化されています'
invalidname: 'ワールド名が不正です'
reseted: '&2%worldname% &eの探索情報をリセットしました'
resetlimit: resetlimit:
help: help:
info: '[player]の上限をリセットします' info: '[player]の上限をリセットします'
@ -416,14 +424,14 @@ command:
info: '[職業名]を離職します' info: '[職業名]を離職します'
args: '[oldplayerjob]' args: '[oldplayerjob]'
success: '%jobname% を離職しました' success: '%jobname% を離職しました'
confirmationNeed: '&cAre you sure you want to leave from&e [jobname]&c job? Type the command again within&6 [time] seconds &cto confirm!' confirmationNeed: '&c本当に &e[jobname] &cから離職しますか 離職する場合は &6[time]&c 秒以内に再度コマンドを実行してください'
leaveall: leaveall:
help: help:
info: 就いている全ての職業を離職します info: 就いている全ての職業を離職します
error: error:
nojobs: 離職できる職業はありません nojobs: 離職できる職業はありません
success: 就いている全ての職業を離職しました success: 就いている全ての職業を離職しました
confirmationNeed: '&cAre you sure you want to leave from all jobs? Type the command again within&6 [time] seconds &cto confirm!' confirmationNeed: '&c本当に &e全てのジョブ&c から離職しますか? 離職する場合は &6[time]&c 秒以内に再度コマンドを実行してください'
explored: explored:
help: help:
info: このチャンクに来たことのある人を確認できます info: このチャンクに来たことのある人を確認できます