设置当前serverId的种子,新种子必须比当前值大。 @param seed new seed. @return true if success.
(long seed)
| 150 | * @return true if success. |
| 151 | */ |
| 152 | public boolean setSeed(long seed) { |
| 153 | try { |
| 154 | return Procedure.Success == Task.runUnsafe(module.zeze.newProcedure(() -> { |
| 155 | var seedKey = new BSeedKey(module.zeze.getConfig().getServerId(), name); |
| 156 | var bAutoKey = module._tAutoKeys.getOrAdd(seedKey); |
| 157 | if (seed > bAutoKey.getNextId()) { |
| 158 | bAutoKey.setNextId(seed); |
| 159 | return 0; |
| 160 | } |
| 161 | return Procedure.LogicError; |
| 162 | }, "AutoKey.setSeed"), DispatchMode.Critical).get(); |
| 163 | } catch (InterruptedException | ExecutionException e) { |
| 164 | throw Task.forceThrow(e); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * 设置当前serverId的种子,新种子必须比当前值大。 |