Jump to content

Chat Handler and All user Commands and Time Handler (on SERVER)


Spycoclown

Recommended Posts

Hallo,

 

hope somebody could help me.

I have 3 Problems:

 

1. Id like to Change the Nickname of a player in the Chat where do i have to hook in?

 

2. I have a command but at the moment the player have to be OP to use it, how can make it that a normal player can use this command?

 

3. I would like to perform an Action every 30 second? how do i can get a Time ticker or something?

 

thx for the help. :)

Spycoclown

Link to comment
Share on other sites

1. take a loot at ServerChatEvent, from code it looks like you can change chat text

 

2. try overriding getRequiredPermissionLevel (haven't tried it, I might be wrong)

 

3. implement ITickHandler (or IScheduledTickHandler) and register it via TickRegistry.registerTickHandler

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

to 1. if i could catch the message befor it get send and then i could cut the username out and replace it, but how do i catch that message?

 

to 2. i will have a try thx

 

and to 3.

Thx, what is better for me ITickHandler oder IScheduledTickHandler? I want to check every 30 second where the player is Standing and if he is in a cold biome i want to harm him

 

Ah and i have a new Questing, in foodstat i can handle what hapend if the foodlvl is low and so on, but it dont work on the Server. in Singleplayer there is no Problem. Where to i can hook in for the foodstat at the server?

Link to comment
Share on other sites

damn it, I changed point 1 but you already answered :D

 

EDIT: to the foodstats, are you sure you're handling it on a server side? it should work same ???.

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

to 1. if i could catch the message befor it get send and then i could cut the username out and replace it, but how do i catch that message?

 

to 2. i will have a try thx

 

and to 3.

Thx, what is better for me ITickHandler oder IScheduledTickHandler? I want to check every 30 second where the player is Standing and if he is in a cold biome i want to harm him

 

Ah and i have a new Questing, in foodstat i can handle what hapend if the foodlvl is low and so on, but it dont work on the Server. in Singleplayer there is no Problem. Where to i can hook in for the foodstat at the server?

 

I suggest you to use an IScheduledTickHandler, since you can specify the ticks which should be between calls (20 ticks = 1 second)

Also keep in mind that you need to register it with TickRegistry.registerScheduledTickHandler

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

I tryed this one but it dont work... what is wrong?

 

 

TickRegistry.registerScheduledTickHandler(new SpyScheduledTickHandler(), this.side);

 

 

public class SpyScheduledTickHandler implements IScheduledTickHandler{

@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	System.out.println("Spy Tick");
}

@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	// TODO Auto-generated method stub

}

@Override
public EnumSet<TickType> ticks() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getLabel() {
	return "SpyTickHandler";
}

@Override
public int nextTickSpacing() {
	return 200;
}

}

Link to comment
Share on other sites

I tryed this one but it dont work... what is wrong?

 

 

TickRegistry.registerScheduledTickHandler(new SpyScheduledTickHandler(), this.side);

 

 

public class SpyScheduledTickHandler implements IScheduledTickHandler{

@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	System.out.println("Spy Tick");
}

@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	// TODO Auto-generated method stub

}

@Override
public EnumSet<TickType> ticks() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getLabel() {
	return "SpyTickHandler";
}

@Override
public int nextTickSpacing() {
	return 200;
}

}

 


@Override
public EnumSet<TickType> ticks() {
	// TODO Auto-generated method stub
	return null;
}

You need to return something here. Example: https://github.com/SanAndreasP/TurretModv3/blob/master/sanandreasp/mods/TurretMod3/registry/SchedTickHandlerWorld.java#L28-L31

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.