Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -99,6 +99,15 @@ public class NetServer implements ApplicationListener{
|
|||||||
private Interval timer = new Interval(10);
|
private Interval timer = new Interval(10);
|
||||||
private IntSet buildHealthChanged = new IntSet();
|
private IntSet buildHealthChanged = new IntSet();
|
||||||
|
|
||||||
|
/** Current kick session. */
|
||||||
|
public @Nullable VoteSession currentlyKicking = null;
|
||||||
|
/** Duration of a kick in seconds. */
|
||||||
|
public static int kickDuration = 60 * 60;
|
||||||
|
/** Voting round duration in seconds. */
|
||||||
|
public static float voteDuration = 0.5f * 60;
|
||||||
|
/** Cooldown between votes in seconds. */
|
||||||
|
public static int voteCooldown = 60 * 5;
|
||||||
|
|
||||||
private ReusableByteOutStream writeBuffer = new ReusableByteOutStream(127);
|
private ReusableByteOutStream writeBuffer = new ReusableByteOutStream(127);
|
||||||
private Writes outputBuffer = new Writes(new DataOutputStream(writeBuffer));
|
private Writes outputBuffer = new Writes(new DataOutputStream(writeBuffer));
|
||||||
|
|
||||||
@@ -340,62 +349,8 @@ public class NetServer implements ApplicationListener{
|
|||||||
Groups.player.each(Player::admin, a -> a.sendMessage(raw, player, args[0]));
|
Groups.player.each(Player::admin, a -> a.sendMessage(raw, player, args[0]));
|
||||||
});
|
});
|
||||||
|
|
||||||
//duration of a kick in seconds
|
|
||||||
int kickDuration = 60 * 60;
|
|
||||||
//voting round duration in seconds
|
|
||||||
float voteDuration = 0.5f * 60;
|
|
||||||
//cooldown between votes in seconds
|
|
||||||
int voteCooldown = 60 * 5;
|
|
||||||
|
|
||||||
class VoteSession{
|
|
||||||
Player target;
|
|
||||||
ObjectIntMap<String> voted = new ObjectIntMap<>();
|
|
||||||
VoteSession[] map;
|
|
||||||
Timer.Task task;
|
|
||||||
int votes;
|
|
||||||
|
|
||||||
public VoteSession(VoteSession[] map, Player target){
|
|
||||||
this.target = target;
|
|
||||||
this.map = map;
|
|
||||||
this.task = Timer.schedule(() -> {
|
|
||||||
if(!checkPass()){
|
|
||||||
Call.sendMessage(Strings.format("[lightgray]Vote failed. Not enough votes to kick[orange] @[lightgray].", target.name));
|
|
||||||
map[0] = null;
|
|
||||||
task.cancel();
|
|
||||||
}
|
|
||||||
}, voteDuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vote(Player player, int d){
|
|
||||||
int lastVote = voted.get(player.uuid(), 0) | voted.get(admins.getInfo(player.uuid()).lastIP, 0);
|
|
||||||
votes -= lastVote;
|
|
||||||
|
|
||||||
votes += d;
|
|
||||||
voted.put(player.uuid(), d);
|
|
||||||
voted.put(admins.getInfo(player.uuid()).lastIP, d);
|
|
||||||
|
|
||||||
Call.sendMessage(Strings.format("[lightgray]@[lightgray] has voted on kicking[orange] @[lightgray].[accent] (@/@)\n[lightgray]Type[orange] /vote <y/n>[] to agree.",
|
|
||||||
player.name, target.name, votes, votesRequired()));
|
|
||||||
|
|
||||||
checkPass();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean checkPass(){
|
|
||||||
if(votes >= votesRequired()){
|
|
||||||
Call.sendMessage(Strings.format("[orange]Vote passed.[scarlet] @[orange] will be banned from the server for @ minutes.", target.name, (kickDuration / 60)));
|
|
||||||
Groups.player.each(p -> p.uuid().equals(target.uuid()), p -> p.kick(KickReason.vote, kickDuration * 1000));
|
|
||||||
map[0] = null;
|
|
||||||
task.cancel();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//cooldowns per player
|
//cooldowns per player
|
||||||
ObjectMap<String, Timekeeper> cooldowns = new ObjectMap<>();
|
ObjectMap<String, Timekeeper> cooldowns = new ObjectMap<>();
|
||||||
//current kick sessions
|
|
||||||
VoteSession[] currentlyKicking = {null};
|
|
||||||
|
|
||||||
clientCommands.<Player>register("votekick", "[player] [reason...]", "Vote to kick a player with a valid reason.", (args, player) -> {
|
clientCommands.<Player>register("votekick", "[player] [reason...]", "Vote to kick a player with a valid reason.", (args, player) -> {
|
||||||
if(!Config.enableVotekick.bool()){
|
if(!Config.enableVotekick.bool()){
|
||||||
@@ -413,7 +368,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentlyKicking[0] != null){
|
if(currentlyKicking != null){
|
||||||
player.sendMessage("[scarlet]A vote is already in progress.");
|
player.sendMessage("[scarlet]A vote is already in progress.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -454,11 +409,11 @@ public class NetServer implements ApplicationListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VoteSession session = new VoteSession(currentlyKicking, found);
|
VoteSession session = new VoteSession(found);
|
||||||
session.vote(player, 1);
|
session.vote(player, 1);
|
||||||
Call.sendMessage(Strings.format("[lightgray]Reason:[orange] @[lightgray].", args[1]));
|
Call.sendMessage(Strings.format("[lightgray]Reason:[orange] @[lightgray].", args[1]));
|
||||||
vtime.reset();
|
vtime.reset();
|
||||||
currentlyKicking[0] = session;
|
currentlyKicking = session;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
player.sendMessage("[scarlet]No player [orange]'" + args[0] + "'[scarlet] found.");
|
player.sendMessage("[scarlet]No player [orange]'" + args[0] + "'[scarlet] found.");
|
||||||
@@ -467,13 +422,13 @@ public class NetServer implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
clientCommands.<Player>register("vote", "<y/n/c>", "Vote to kick the current player. Admin can cancel the voting with 'c'.", (arg, player) -> {
|
clientCommands.<Player>register("vote", "<y/n/c>", "Vote to kick the current player. Admin can cancel the voting with 'c'.", (arg, player) -> {
|
||||||
if(currentlyKicking[0] == null){
|
if(currentlyKicking == null){
|
||||||
player.sendMessage("[scarlet]Nobody is being voted on.");
|
player.sendMessage("[scarlet]Nobody is being voted on.");
|
||||||
}else{
|
}else{
|
||||||
if(player.admin && arg[0].equalsIgnoreCase("c")){
|
if(player.admin && arg[0].equalsIgnoreCase("c")){
|
||||||
Call.sendMessage(Strings.format("[lightgray]Vote canceled by admin[orange] @[lightgray].", player.name));
|
Call.sendMessage(Strings.format("[lightgray]Vote canceled by admin[orange] @[lightgray].", player.name));
|
||||||
currentlyKicking[0].task.cancel();
|
currentlyKicking.task.cancel();
|
||||||
currentlyKicking[0] = null;
|
currentlyKicking = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,17 +444,17 @@ public class NetServer implements ApplicationListener{
|
|||||||
};
|
};
|
||||||
|
|
||||||
//hosts can vote all they want
|
//hosts can vote all they want
|
||||||
if((currentlyKicking[0].voted.get(player.uuid(), 2) == sign || currentlyKicking[0].voted.get(admins.getInfo(player.uuid()).lastIP, 2) == sign)){
|
if((currentlyKicking.voted.get(player.uuid(), 2) == sign || currentlyKicking.voted.get(admins.getInfo(player.uuid()).lastIP, 2) == sign)){
|
||||||
player.sendMessage(Strings.format("[scarlet]You've already voted @. Sit down.", arg[0].toLowerCase()));
|
player.sendMessage(Strings.format("[scarlet]You've already voted @. Sit down.", arg[0].toLowerCase()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentlyKicking[0].target == player){
|
if(currentlyKicking.target == player){
|
||||||
player.sendMessage("[scarlet]You can't vote on your own trial.");
|
player.sendMessage("[scarlet]You can't vote on your own trial.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentlyKicking[0].target.team() != player.team()){
|
if(currentlyKicking.target.team() != player.team()){
|
||||||
player.sendMessage("[scarlet]You can't vote for other teams.");
|
player.sendMessage("[scarlet]You can't vote for other teams.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -509,7 +464,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentlyKicking[0].vote(player, sign);
|
currentlyKicking.vote(player, sign);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1125,6 +1080,49 @@ public class NetServer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class VoteSession{
|
||||||
|
Player target;
|
||||||
|
ObjectIntMap<String> voted = new ObjectIntMap<>();
|
||||||
|
Timer.Task task;
|
||||||
|
int votes;
|
||||||
|
|
||||||
|
public VoteSession(Player target){
|
||||||
|
this.target = target;
|
||||||
|
this.task = Timer.schedule(() -> {
|
||||||
|
if(!checkPass()){
|
||||||
|
Call.sendMessage(Strings.format("[lightgray]Vote failed. Not enough votes to kick[orange] @[lightgray].", target.name));
|
||||||
|
currentlyKicking = null;
|
||||||
|
task.cancel();
|
||||||
|
}
|
||||||
|
}, voteDuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vote(Player player, int d){
|
||||||
|
int lastVote = voted.get(player.uuid(), 0) | voted.get(admins.getInfo(player.uuid()).lastIP, 0);
|
||||||
|
votes -= lastVote;
|
||||||
|
|
||||||
|
votes += d;
|
||||||
|
voted.put(player.uuid(), d);
|
||||||
|
voted.put(admins.getInfo(player.uuid()).lastIP, d);
|
||||||
|
|
||||||
|
Call.sendMessage(Strings.format("[lightgray]@[lightgray] has voted on kicking[orange] @[lightgray].[accent] (@/@)\n[lightgray]Type[orange] /vote <y/n>[] to agree.",
|
||||||
|
player.name, target.name, votes, votesRequired()));
|
||||||
|
|
||||||
|
checkPass();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean checkPass(){
|
||||||
|
if(votes >= votesRequired()){
|
||||||
|
Call.sendMessage(Strings.format("[orange]Vote passed.[scarlet] @[orange] will be banned from the server for @ minutes.", target.name, (kickDuration / 60)));
|
||||||
|
Groups.player.each(p -> p.uuid().equals(target.uuid()), p -> p.kick(KickReason.vote, kickDuration * 1000));
|
||||||
|
currentlyKicking = null;
|
||||||
|
task.cancel();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public interface TeamAssigner{
|
public interface TeamAssigner{
|
||||||
Team assign(Player player, Iterable<Player> players);
|
Team assign(Player player, Iterable<Player> players);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -997,6 +997,10 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
return consume(new ConsumeCoolant(amount));
|
return consume(new ConsumeCoolant(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConsumeCoolant consumeCoolant(float amount, boolean allowLiquid, boolean allowGas){
|
||||||
|
return consume(new ConsumeCoolant(amount, allowLiquid, allowGas));
|
||||||
|
}
|
||||||
|
|
||||||
public <T extends Consume> T consume(T consume){
|
public <T extends Consume> T consume(T consume){
|
||||||
if(consume instanceof ConsumePower){
|
if(consume instanceof ConsumePower){
|
||||||
//there can only be one power consumer
|
//there can only be one power consumer
|
||||||
|
|||||||
@@ -3,10 +3,18 @@ package mindustry.world.consumers;
|
|||||||
/** A ConsumeLiquidFilter that consumes specific coolant, selected based on stats. */
|
/** A ConsumeLiquidFilter that consumes specific coolant, selected based on stats. */
|
||||||
public class ConsumeCoolant extends ConsumeLiquidFilter{
|
public class ConsumeCoolant extends ConsumeLiquidFilter{
|
||||||
public float maxTemp = 0.5f, maxFlammability = 0.1f;
|
public float maxTemp = 0.5f, maxFlammability = 0.1f;
|
||||||
|
public boolean allowLiquid = true, allowGas = false;
|
||||||
|
|
||||||
|
public ConsumeCoolant(float amount, boolean allowLiquid, boolean allowGas){
|
||||||
|
this.allowLiquid = allowLiquid;
|
||||||
|
this.allowGas = allowGas;
|
||||||
|
|
||||||
|
this.filter = liquid -> liquid.coolant && (this.allowLiquid && !liquid.gas || this.allowGas && liquid.gas) && liquid.temperature <= maxTemp && liquid.flammability < maxFlammability;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
public ConsumeCoolant(float amount){
|
public ConsumeCoolant(float amount){
|
||||||
this.filter = liquid -> liquid.coolant && !liquid.gas && liquid.temperature <= maxTemp && liquid.flammability < maxFlammability;
|
this(amount, true, false);
|
||||||
this.amount = amount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConsumeCoolant(){
|
public ConsumeCoolant(){
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
"address": ["0nera.ru:7777"]
|
"address": ["0nera.ru:7777"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Voiddustry Network",
|
"name": "Untitled Mindustry Servers",
|
||||||
"address": ["45.144.66.250:6566", "45.144.66.250:6567" ,"45.144.66.250:6565", "45.144.66.250:6561"]
|
"address": ["45.144.66.250:6567", "45.144.66.250:6501"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "C.A.M.S.",
|
"name": "C.A.M.S.",
|
||||||
|
|||||||
Reference in New Issue
Block a user